From c71f9ef67fda2addd1e8bb797a5945c0efbc5a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Fri, 3 Mar 2023 21:49:38 +0100 Subject: [PATCH] streamline plugin output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hervé Boutemy --- README.md | 2 +- src/it/makeAggregateBom/verify.groovy | 6 ++---- .../org/cyclonedx/maven/BaseCycloneDxMojo.java | 14 +++++++------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 8ee809ea..1df44bd4 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Default Values all bom ${project.build.directory} - true + false diff --git a/src/it/makeAggregateBom/verify.groovy b/src/it/makeAggregateBom/verify.groovy index f04fc5d1..5228fda4 100644 --- a/src/it/makeAggregateBom/verify.groovy +++ b/src/it/makeAggregateBom/verify.groovy @@ -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() diff --git a/src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java b/src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java index f4dc9683..16e588fa 100644 --- a/src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java +++ b/src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java @@ -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; @@ -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"; /** @@ -266,7 +266,7 @@ public void execute() throws MojoExecutionException { private void generateBom(String analysis, Metadata metadata, Set components, Set 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)); @@ -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); } }