This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch lock-down-classifier in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git
commit a44eb5ab50ade21b9aefa41f5f7884a34023ea77 Author: Michael Osipov <micha...@apache.org> AuthorDate: Fri Jun 7 23:54:02 2024 +0200 [MDEP-939] Lock down classifier in dependency:sources goal This closes #409 --- src/it/projects/sources/test.properties | 1 + .../resolvers/ResolveDependencySourcesMojo.java | 19 +++++-------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/it/projects/sources/test.properties b/src/it/projects/sources/test.properties index 238ec42e..e8b98f03 100644 --- a/src/it/projects/sources/test.properties +++ b/src/it/projects/sources/test.properties @@ -16,3 +16,4 @@ # under the License. outputFile = target/resolved.txt +classifier = foo diff --git a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java index f4871de0..fd743f46 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java @@ -18,9 +18,9 @@ */ package org.apache.maven.plugins.dependency.resolvers; -import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; /** @@ -36,19 +36,10 @@ import org.apache.maven.plugins.annotations.ResolutionScope; threadSafe = true) public class ResolveDependencySourcesMojo extends ResolveDependenciesMojo { - private static final String SOURCE_CLASSIFIER = "sources"; + private static final String SOURCES_CLASSIFIER = "sources"; - /** - * Main entry into mojo. Gets the list of dependencies and iterates through resolving the source jars. - * - * @throws MojoExecutionException with a message if an error occurs. - */ - @Override - protected void doExecute() throws MojoExecutionException { - if (this.classifier == null || this.classifier.isEmpty()) { - this.classifier = SOURCE_CLASSIFIER; - } - - super.doExecute(); + @Parameter(name = "classifier", defaultValue = SOURCES_CLASSIFIER, readonly = true) + public void setClassifier(String classifier) { + this.classifier = classifier; } }