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

streamline plugin output #304

Merged
merged 1 commit into from
Mar 7, 2023
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Default Values
<outputFormat>all</outputFormat>
<outputName>bom</outputName>
<outputDirectory>${project.build.directory}</outputDirectory><!-- usually target, if not redefined in pom.xml -->
<verbose>true</verbose><!-- = ${cyclonedx.verbose} -->
<verbose>false</verbose><!-- = ${cyclonedx.verbose} -->
</configuration>
</plugin>
</plugins>
Expand Down
6 changes: 2 additions & 4 deletions src/it/makeAggregateBom/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ assert 2 == (buildLog =~ /\[INFO\] CycloneDX: Resolving Aggregated Dependencies/
// 13 = 6 modules for main cyclonedx-makeAggregateBom execution
// + 1 for root module cyclonedx-makeAggregateBom-root-only execution
// + 6 modules for additional cyclonedx-makeBom execution
assert 13 == (buildLog =~ /\[INFO\] CycloneDX: Writing BOM \(XML\)/).size()
assert 13 == (buildLog =~ /\[INFO\] CycloneDX: Validating BOM \(XML\)/).size()
assert 13 == (buildLog =~ /\[INFO\] CycloneDX: Writing BOM \(JSON\)/).size()
assert 13 == (buildLog =~ /\[INFO\] CycloneDX: Validating BOM \(JSON\)/).size()
assert 13 == (buildLog =~ /\[INFO\] CycloneDX: Writing and validating BOM \(XML\)/).size()
assert 13 == (buildLog =~ /\[INFO\] CycloneDX: Writing and validating BOM \(JSON\)/).size()
// cyclonedx-makeAggregateBom-root-only execution skips 5 non-root modules
assert 5 == (buildLog =~ /\[INFO\] Skipping CycloneDX on non-execution root/).size()

Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ public abstract class BaseCycloneDxMojo extends AbstractMojo {
* @since 2.6.0
*/
@SuppressWarnings("CanBeFinal")
@Parameter(property = "cyclonedx.verbose", defaultValue = "true", required = false)
private boolean verbose = true;
@Parameter(property = "cyclonedx.verbose", defaultValue = "false", required = false)
private boolean verbose = false;

@org.apache.maven.plugins.annotations.Component
private MavenProjectHelper mavenProjectHelper;
Expand All @@ -204,10 +204,10 @@ public abstract class BaseCycloneDxMojo extends AbstractMojo {
*/
protected static final String MESSAGE_RESOLVING_DEPS = "CycloneDX: Resolving Dependencies";
protected static final String MESSAGE_RESOLVING_AGGREGATED_DEPS = "CycloneDX: Resolving Aggregated Dependencies";
protected static final String MESSAGE_CREATING_BOM = "CycloneDX: Creating BOM";
protected static final String MESSAGE_CREATING_BOM = "CycloneDX: Creating BOM version %s with %d component(s)";
static final String MESSAGE_CALCULATING_HASHES = "CycloneDX: Calculating Hashes";
protected static final String MESSAGE_WRITING_BOM = "CycloneDX: Writing BOM (%s): %s";
protected static final String MESSAGE_VALIDATING_BOM = "CycloneDX: Validating BOM (%s): %s";
protected static final String MESSAGE_WRITING_BOM = "CycloneDX: Writing and validating BOM (%s): %s";
protected static final String MESSAGE_ATTACHING_BOM = " attaching as %s-%s-cyclonedx.%s";
protected static final String MESSAGE_VALIDATION_FAILURE = "The BOM does not conform to the CycloneDX BOM standard as defined by the XSD";

/**
Expand Down Expand Up @@ -266,7 +266,7 @@ public void execute() throws MojoExecutionException {

private void generateBom(String analysis, Metadata metadata, Set<Component> components, Set<Dependency> dependencies) throws MojoExecutionException {
try {
getLog().info(MESSAGE_CREATING_BOM);
getLog().info(String.format(MESSAGE_CREATING_BOM, schemaVersion, components.size()));
final Bom bom = new Bom();
bom.setComponents(new ArrayList<>(components));

Expand Down Expand Up @@ -323,12 +323,12 @@ private void saveBomToFile(String bomString, String extension, Parser bomParser)
getLog().info(String.format(MESSAGE_WRITING_BOM, extension.toUpperCase(), bomFile.getAbsolutePath()));
FileUtils.write(bomFile, bomString, StandardCharsets.UTF_8, false);

getLog().info(String.format(MESSAGE_VALIDATING_BOM, extension.toUpperCase(), bomFile.getAbsolutePath()));
if (!bomParser.isValid(bomFile, schemaVersion())) {
throw new MojoExecutionException(MESSAGE_VALIDATION_FAILURE);
}

if (!skipAttach) {
getLog().info(String.format(MESSAGE_ATTACHING_BOM, project.getArtifactId(), project.getVersion(), extension));
mavenProjectHelper.attachArtifact(project, extension, "cyclonedx", bomFile);
}
}
Expand Down