Skip to content

Commit 04c3216

Browse files
committed
[MDEP-939] Lock down classifier in dependency:sources goal
This closes #409
1 parent 9fd4ed5 commit 04c3216

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

src/it/projects/sources/test.properties

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# to you under the Apache License, Version 2.0 (the
66
# "License"); you may not use this file except in compliance
77
# with the License. You may obtain a copy of the License at
8-
#
8+
#
99
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
10+
#
1111
# Unless required by applicable law or agreed to in writing,
1212
# software distributed under the License is distributed on an
1313
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -16,3 +16,5 @@
1616
# under the License.
1717

1818
outputFile = target/resolved.txt
19+
# This is intentional to prove that no classifier is passed (read-only value)
20+
classifier = foo

src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependencySourcesMojo.java

+5-14
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
*/
1919
package org.apache.maven.plugins.dependency.resolvers;
2020

21-
import org.apache.maven.plugin.MojoExecutionException;
2221
import org.apache.maven.plugins.annotations.LifecyclePhase;
2322
import org.apache.maven.plugins.annotations.Mojo;
23+
import org.apache.maven.plugins.annotations.Parameter;
2424
import org.apache.maven.plugins.annotations.ResolutionScope;
2525

2626
/**
@@ -36,19 +36,10 @@
3636
threadSafe = true)
3737
public class ResolveDependencySourcesMojo extends ResolveDependenciesMojo {
3838

39-
private static final String SOURCE_CLASSIFIER = "sources";
39+
private static final String SOURCES_CLASSIFIER = "sources";
4040

41-
/**
42-
* Main entry into mojo. Gets the list of dependencies and iterates through resolving the source jars.
43-
*
44-
* @throws MojoExecutionException with a message if an error occurs.
45-
*/
46-
@Override
47-
protected void doExecute() throws MojoExecutionException {
48-
if (this.classifier == null || this.classifier.isEmpty()) {
49-
this.classifier = SOURCE_CLASSIFIER;
50-
}
51-
52-
super.doExecute();
41+
@Parameter(name = "classifier", defaultValue = SOURCES_CLASSIFIER, readonly = true)
42+
public void setClassifier(String classifier) {
43+
this.classifier = classifier;
5344
}
5445
}

0 commit comments

Comments
 (0)