Skip to content

Commit dbdda0c

Browse files
committed
[MDEP-941] Deprecate dependency:sources in favor of dependency:resolve-sources
This closes #411
1 parent f090b5e commit dbdda0c

File tree

7 files changed

+102
-62
lines changed

7 files changed

+102
-62
lines changed

src/it/projects/sources/invoker.properties src/it/projects/resolve-sources/invoker.properties

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
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
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:sources
18+
invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:resolve-sources

src/it/projects/sources/pom.xml src/it/projects/resolve-sources/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
<name>Test</name>
3131
<description>
32-
Test dependency:sources
32+
Test dependency:resolve-sources
3333
</description>
3434

3535
<properties>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.plugins.dependency.resolvers;
20+
21+
import org.apache.maven.plugins.annotations.LifecyclePhase;
22+
import org.apache.maven.plugins.annotations.Mojo;
23+
import org.apache.maven.plugins.annotations.ResolutionScope;
24+
25+
/**
26+
* Goal that resolves the project source dependencies from the repository.
27+
*
28+
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
29+
* @since 2.0-alpha2
30+
* @deprecated in favor of {@code resolve-sources} goal and will be removed in a future version
31+
*/
32+
@Mojo(
33+
name = "sources",
34+
defaultPhase = LifecyclePhase.GENERATE_SOURCES,
35+
requiresDependencyResolution = ResolutionScope.TEST,
36+
threadSafe = true)
37+
@Deprecated
38+
public class OldResolveDependencySourcesMojo extends ResolveDependencySourcesMojo {}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
* Goal that resolves the project source dependencies from the repository.
2828
*
2929
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
30-
* @since 2.0-alpha2
30+
* @since 2.0-alpha2/3.7.0
3131
*/
3232
@Mojo(
33-
name = "sources",
33+
name = "resolve-sources",
3434
defaultPhase = LifecyclePhase.GENERATE_SOURCES,
3535
requiresDependencyResolution = ResolutionScope.TEST,
3636
threadSafe = true)

src/site/apt/index.apt.vm

+4-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ ${project.name}
6161
optionally transitive dependencies and copies them to a specified location, stripping the version if desired.
6262
This goal can also be run from the command line.
6363

64-
*{{{./display-ancestors-mojo.html}dependency:display-ancestors}} displays all ancestor POMs of the project.
64+
*{{{./display-ancestors-mojo.html}dependency:display-ancestors}} displays all ancestor POMs of the project.
6565
This may be useful in a continuous integration system where you want to know all parent poms of the project.
6666
This goal can also be run from the command line.
6767

@@ -88,9 +88,11 @@ ${project.name}
8888

8989
*{{{./resolve-plugins-mojo.html}dependency:resolve-plugins}} tells Maven to resolve plugins and their dependencies.
9090

91-
*{{{./sources-mojo.html}dependency:sources}} tells Maven to resolve all dependencies and their source attachments,
91+
*{{{./resolve-sources-mojo.html}dependency:resolve-sources}} tells Maven to resolve all dependencies and their source attachments,
9292
and displays the version.
9393

94+
*{{{./sources-mojo.html}dependency:sources}} has been deprecated for removal in favor of {{{./resolve-sources-mojo.html}dependency:resolve-sources}}.
95+
9496
*{{{./tree-mojo.html}dependency:tree}} displays the dependency tree for this project.
9597

9698
*{{{./unpack-mojo.html}dependency:unpack}} like copy but unpacks.

src/site/apt/usage.apt.vm

+54-54
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1414
~~ KIND, either express or implied. See the License for the
1515
~~ specific language governing permissions and limitations
16-
~~ under the License.
17-
16+
~~ under the License.
17+
1818
------
1919
Usage
2020
------
@@ -25,20 +25,20 @@
2525
------
2626

2727
Usage
28-
28+
2929
Brief examples on how to use the dependency goals:
3030

3131
%{toc|fromDepth=2}
32-
32+
3333
* <<<dependency:copy>>>
3434

3535
This goal is meant to be bound to a lifecycle phase and configured in your
3636
<<<pom.xml>>>. It will resolve the artifact from the repository and place a copy
3737
in the specified location. Multiple artifacts can be defined in a single
3838
execution. A default output directory is specified but can be overridden for
3939
each ArtifactItem by setting the optional outputDirectory field. An
40-
optional new name can be set to rename or the version stripped while copying.
41-
40+
optional new name can be set to rename or the version stripped while copying.
41+
4242
The artifact version is optional. If not set, the plugin will attempt to resolve it from the
4343
project dependencies and then the dependencyManagement section.
4444

@@ -87,7 +87,7 @@ Usage
8787
[...]
8888
</project>
8989
+---+
90-
90+
9191
If you intend to configure this goal for execution on the command line using:
9292

9393
+---+
@@ -128,28 +128,28 @@ mvn dependency:copy
128128
+---+
129129

130130
<Notes:>
131-
132-
* By default, artifacts are copied into <outputDirectory> using
131+
132+
* By default, artifacts are copied into <outputDirectory> using
133133
Maven artifact file name convention ( ie <artifactId-version-classifier.type> ).
134134
Use the following rules to override the default convention:
135-
136-
* Use <artifactItem.destFileName> to override the default file name.
137-
135+
136+
* Use <artifactItem.destFileName> to override the default file name.
137+
138138
* Use <stripVersion> to remove <version> from default file name.
139139
This field is ignored when <artifactId.destFileName> is set.
140-
141-
* Use <artifactItem.outputDirectory> to override the plugin's <outputDirectory> configuration
140+
141+
* Use <artifactItem.outputDirectory> to override the plugin's <outputDirectory> configuration
142142
per <artifactItem>.
143-
143+
144144
[]
145-
145+
146146
[]
147147

148148
* <<<dependency:copy-dependencies>>>
149149

150150
This goal can be bound to a lifecycle phase and configured in your <<<pom.xml>>>.
151151
It will resolve the dependencies (including transitive dependencies) from
152-
the repository and place a copy in the specified location.
152+
the repository and place a copy in the specified location.
153153

154154
The artifacts can be placed in subfolders based on type. For example:
155155

@@ -171,7 +171,7 @@ mvn dependency:copy
171171
<<<mvn dependency:copy-dependencies -Dclassifier=sources>>> will try to find
172172
the sources for all dependencies and copy them.
173173

174-
Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc), groupId, artifactId, or a combination of them.
174+
Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc), groupId, artifactId, or a combination of them.
175175

176176
<<Note:>> As of 2.0-alpha-5, you may mix includes and excludes of the same category (ie scope). Includes are processed before excludes.
177177

@@ -216,18 +216,18 @@ mvn dependency:copy
216216
It will resolve the artifact from the repository and place a copy in the
217217
specified location. Multiple artifacts can be defined in a single execution.
218218
A default outputDirectory is specified but can be overridden for each
219-
ArtifactItem by setting the optional outputDirectory field.
220-
219+
ArtifactItem by setting the optional outputDirectory field.
220+
221221
A single artifact can be unpacked multiple times if different include/exclude parameters
222222
are defined for each artifactItem
223223

224224
See the {{{#Overwrite_Rules}Overwrite Rules}} section for rules about how overwriting is handled.
225225

226226
The artifact version is optional. If not set, the plugin will attempt to resolve it from the
227227
project dependencies and then the dependencyManagement section.
228-
228+
229229
Configure the plugin something like this if you intend to bind it to execute along with your build:
230-
230+
231231
+---+
232232
<project>
233233
[...]
@@ -328,15 +328,15 @@ mvn dependency:unpack
328328
resolve artifacts with the classifier and type. For example:
329329
<<<mvn dependency:unpack-dependencies -Dclassifier=sources>>> will try to find
330330
the sources for all dependencies and unpack them.
331-
331+
332332
Filters can be applied to include or exclude certain file or filesets as necessary
333-
334-
Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc), groupId, artifactId, or a combination of them.
333+
334+
Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc), groupId, artifactId, or a combination of them.
335335

336336
<<Note:>> You can mix includes and excludes of the same category (i.e. scope). Includes are processed before excludes.
337337

338338
See the {{{#Overwrite_Rules}Overwrite Rules}} section for rules about how overwriting is handled.
339-
339+
340340
The goal can also be launched from the command line like:
341341
<<<mvn dependency:unpack-dependencies [optional params]>>>
342342

@@ -373,31 +373,31 @@ mvn dependency:unpack
373373
Artifacts are copied or unpacked using the following rules:
374374

375375
* If the artifact doesn't exist in the destination, then copy/unpack it.
376-
376+
377377
Otherwise:
378-
378+
379379
* For copy/unpack goal only: if <<<artifactItem / overWrite>>> or <<<overWrite>>> is true, then it will force an overwrite.
380-
380+
381381
* Releases check the <<<overWriteReleases>>> value (default = false). If true, then it will force an overwrite.
382382

383383
* Snapshots check the <<<overWriteSnapshots>>> value (default = false). If true, then it will force an overwrite.
384-
384+
385385
* If none of the above is set to true, then it defaults to the <<<overWriteIfNewer>>> value (default = true). This value, if true, causes
386386
the plugin to only copy if the source is newer than the destination (or it doesn't exist in the destination). (for unpack, this checks the existence of the marker file, created in the <<<markersDirectory>>> path.
387387
To avoid unexpected behavior after <<<mvn clean>>>, this path should normally be contained within the <<</target>>> hierarchy.)
388-
388+
389389
Examples:
390-
390+
391391
* Using the default settings (<<<overWriteReleases>>> = false, <<<overWriteSnapshots>>> = false, <<<overWriteIfNewer>>> = true), then a release or snapshot artifact will
392392
only over write the destination if the source is newer than the destination (or marker file if unpacking).
393-
393+
394394
* If <<<overWriteReleases>>> = true, then a release artifact (ie <<<foo-1.0.jar>>>) will always overwrite.
395-
395+
396396
* If <<<overWriteSnapshots>>> = true, then a snapshot artifact (ie <<<foo-1.0-SNAPSHOT.jar>>>) will always overwrite.
397-
397+
398398
* If all of the values are false, then a copy/unpack will only occur if it doesn't exist in the destination (or <<<markersDirectory>>> if unpacking).
399-
400-
399+
400+
401401

402402
* <<<dependency:resolve>>>
403403

@@ -419,15 +419,15 @@ mvn dependency:unpack
419419
<<<mvn dependency:resolve -Dclassifer=test-jar>>> will try to find the
420420
test-jar for all dependencies resolve them to the local repository.
421421

422-
* <<<dependency:sources>>>
422+
* <<<dependency:resolve-sources>>>
423423

424-
Sources is intended to be used from the command line like:
425-
<<<mvn dependency:sources -Dsilent=true>>>
424+
Resolve-sources is intended to be used from the command line like:
425+
<<<mvn dependency:resolve-sources -Dsilent=true>>>
426426

427427
This is the same as the resolve goal except it includes the source
428428
attachments if they exist. This is useful when you want to download source
429-
attachments to your local repository.
430-
429+
attachments to your local repository.
430+
431431
You can also define the <<<markersDirectory>>> either in the pom or settings
432432
to be a common location for all projects. This allows the system to resolve sources faster for dependencies that don't
433433
have the sources published. The plugin will store a marker file to describe if the sources were resolved or not. By placing
@@ -452,7 +452,7 @@ mvn dependency:unpack
452452
(or projects, in the case of a multimodule build) from the local repository.
453453
Purges can be run with a variety of limiting parameters, including artifact
454454
exclusions, limiting to direct dependencies only, and different levels of
455-
depth for deletion. By default, deleted artifacts can be re-resolved
455+
depth for deletion. By default, deleted artifacts can be re-resolved
456456
afterwards; you can disable this by specifying <<<-DreResolve=false>>>.
457457

458458
In its simplest form, the goal can be called like this:
@@ -468,7 +468,7 @@ mvn dependency:purge-local-repository
468468
mvn dependency:purge-local-repository -Dexclude=org.apache.maven:maven-plugin-api
469469
+---+
470470

471-
<<Note:>> The <<<exclude>>> parameter is a comma-delimited list of
471+
<<Note:>> The <<<exclude>>> parameter is a comma-delimited list of
472472
groupId:artifactId pairs. It has a corresponding List-based parameter -
473473
<<<excludes>>> - for convenient use inside the POM.
474474

@@ -529,7 +529,7 @@ mvn dependency:analyze
529529

530530
* <<<dependency:analyze-dep-mgt>>>
531531

532-
This goal looks at the dependencies after final resolution and looks for mismatches in your dependencyManagement section.
532+
This goal looks at the dependencies after final resolution and looks for mismatches in your dependencyManagement section.
533533
In versions of maven prior to 2.0.6, it was possible to inherit versions that didn't match your dependencyManagement. See {{{https://issues.apache.org/jira/browse/MNG-1577}MNG-1577}} for more info.
534534

535535
If this goal detects issues, you should attempt to resolve the discrepancies before upgrading to 2.0.6 to avoid any surprises. This can be done by upgrading or downgrading the version in dependencyManagement to match what is actually
@@ -559,7 +559,7 @@ mvn dependency:analyze-dep-mgt
559559
[INFO] Resolved: 2.4
560560
[WARNING] Potential problems found in Dependency Management
561561
+---+
562-
562+
563563

564564
* <<<dependency:analyze-report>>>
565565

@@ -624,15 +624,15 @@ mvn dependency:tree -DoutputFile=/path/to/file.graphml -DoutputType=graphml
624624
* <<<dependency:build-classpath>>>
625625

626626
Since: 2.0-alpha-2
627-
627+
628628
This goal will output a classpath string of dependencies from the local repository to a file or log and optionally attach and deploy the file. For instance, the file would contain a classpath string like this:
629629

630630
+---+
631631
/home/foo/.m2/repository/org/java/utils/util/util-1.0.jar:/home/foo/.m2/ ....
632-
+---+
632+
+---+
633633

634634
The resulting file could then be used like this:
635-
635+
636636
+---+
637637
java -cp `cat resultFile` MyClass
638638
+---+
@@ -650,8 +650,8 @@ mvn dependency:build-classpath -Dmdep.outputFile=cp.txt
650650
+---+
651651

652652
The goal can also be bound to a lifecycle phase with the following configuration:
653-
654-
+---+
653+
654+
+---+
655655
<project>
656656
[...]
657657
<build>
@@ -682,7 +682,7 @@ mvn dependency:build-classpath -Dmdep.outputFile=cp.txt
682682

683683
* <<<dependency:list-repositories>>>
684684

685-
This goal lists all the repositories that this build depends upon. It shows repositories defined in your settings,
685+
This goal lists all the repositories that this build depends upon. It shows repositories defined in your settings,
686686
poms, and declared in transitive dependency poms.
687687

688688

@@ -692,7 +692,7 @@ mvn dependency:build-classpath -Dmdep.outputFile=cp.txt
692692

693693
+-----+
694694
mvn dependency:get -DgroupId=org.apache.maven -DartifactId=maven-core -Dversion=2.2.1 -Dpackaging=jar -Dclassifier=sources -DremoteRepositories=central::default::https://repo.maven.apache.org/maven2,myrepo::::http://myrepo.com/maven2
695-
mvn dependency:get -DgroupId=org.apache.maven -DartifactId=maven-core -Dversion=2.2.1 -Dpackaging=jar -Dclassifier=sources -DremoteRepositories=https://repo.maven.apache.org/maven2
695+
mvn dependency:get -DgroupId=org.apache.maven -DartifactId=maven-core -Dversion=2.2.1 -Dpackaging=jar -Dclassifier=sources -DremoteRepositories=https://repo.maven.apache.org/maven2
696696
mvn dependency:get -Dartifact=org.apache.maven:maven-core:2.2.1:jar:sources -DremoteRepositories=https://repo.maven.apache.org/maven2 -Ddest=/tmp/myfile.jar
697697
+-----+
698698

@@ -715,4 +715,4 @@ mvn dependency:analyze-exclusions
715715
[WARNING] org.apache.maven:maven-artifact:
716716
[WARNING] - javax.annotation:javax.annotation-api
717717
[WARNING] - javax.activation:javax.activation-api
718-
+---+
718+
+---+

0 commit comments

Comments
 (0)