From 285a41193e8c159c11f36a315254fb3e0296848c Mon Sep 17 00:00:00 2001 From: Michael Walser Date: Fri, 7 Nov 2025 12:09:26 +0100 Subject: [PATCH] Only log dependency classpath when no property/file output is specified --- .../fromDependencies/BuildClasspathMojo.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java index c0cc14f03..b1584a70c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java @@ -91,12 +91,14 @@ public class BuildClasspathMojo extends AbstractDependencyFilterMojo implements /** * If defined, the name of a property to which the classpath string will be written. + * If neither this nor the outputFile parameter is set, the classpath will be logged at INFO level. */ @Parameter(property = "mdep.outputProperty") private String outputProperty; /** - * The file to write the classpath string. If undefined, it just prints the classpath as [INFO]. + * If defined, the file to which the classpath string will be written. + * If neither this nor the outputProperty parameter is set, the classpath will be logged at INFO level. */ @Parameter(property = "mdep.outputFile") private File outputFile; @@ -237,15 +239,18 @@ protected void doExecute() throws MojoExecutionException { } } - if (outputFile == null) { - getLog().info("Dependencies classpath:" + System.lineSeparator() + cpString); - } else { + if (outputFile != null) { if (regenerateFile || !isUpToDate(cpString)) { storeClasspathFile(cpString, outputFile); } else { this.getLog().info("Skipped writing classpath file '" + outputFile + "'. No changes found."); } } + + if (outputProperty == null && outputFile == null) { + getLog().info("Dependencies classpath:" + System.lineSeparator() + cpString); + } + if (attach) { attachFile(cpString); }