Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make log output more easy to understand by sorting #542

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.cyclonedx.model.Component;
import org.cyclonedx.model.Dependency;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -117,9 +118,10 @@ protected String extractComponentsAndDependencies(final Set<String> topLevelComp
// root project: analyze and aggregate all the modules
getLog().info((reactorProjects.size() <= 1) ? MESSAGE_RESOLVING_DEPS : MESSAGE_RESOLVING_AGGREGATED_DEPS);

final List<String> excludedProjects = new ArrayList<>();
for (final MavenProject mavenProject : reactorProjects) {
if (shouldExclude(mavenProject)) {
getLog().info("Excluding " + mavenProject.getArtifactId());
excludedProjects.add(mavenProject.getArtifactId());
continue;
}

Expand All @@ -135,6 +137,8 @@ protected String extractComponentsAndDependencies(final Set<String> topLevelComp
projectDependencies.forEach(dependencies::putIfAbsent);
}

excludedProjects.stream().sorted(String.CASE_INSENSITIVE_ORDER).forEach(excluded -> getLog().info("Excluding " + excluded));

addMavenProjectsAsParentDependencies(reactorProjects, dependencies);

return "makeAggregateBom";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@
import org.slf4j.LoggerFactory;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -242,6 +244,7 @@ public void cleanupBomDependencies(Metadata metadata, Map<String, Component> com

// Check all BOM components have an associated BOM dependency

final List<String> notDepended = new ArrayList<>();
for (Iterator<Map.Entry<String, Component>> it = components.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<String, Component> entry = it.next();
if (!dependencies.containsKey(entry.getKey())) {
Expand All @@ -250,10 +253,12 @@ public void cleanupBomDependencies(Metadata metadata, Map<String, Component> com
}
it.remove();
} else if (!dependsOns.contains(entry.getKey())) {
logger.warn("BOM dependency listed but is not depended upon: " + entry.getKey());
notDepended.add(entry.getKey());
}
}

notDepended.stream().sorted(String.CASE_INSENSITIVE_ORDER).forEach(dependency -> logger.warn("BOM dependency listed but is not depended upon: " + dependency));

// include BOM main component
Component main = metadata.getComponent();
final String mainBomRef = main.getBomRef();
Expand Down