You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Alberto Gallardo (Jira)" <ji...@apache.org> on 2021/04/20 11:15:00 UTC
[jira] [Created] (MDEP-745) copy-dependencies should not fetch
dependencies out of the chosen scope
Alberto Gallardo created MDEP-745:
-------------------------------------
Summary: copy-dependencies should not fetch dependencies out of the chosen scope
Key: MDEP-745
URL: https://issues.apache.org/jira/browse/MDEP-745
Project: Maven Dependency Plugin
Issue Type: Improvement
Components: copy-dependencies
Affects Versions: 3.1.2
Reporter: Alberto Gallardo
Copying {{runtime}} dependencies of a maven submodule fails due to a {{provided}} inter-module dependency. This is not expected, as neither the {{provided}} dependency nor its transitive dependencies should be copied. There is no need to fetch the dependency.
Notice that it is still possible to copy the dependencies if first invoking the {{install}} goal, but this should not be necessary.
h2. Project structure
{code:java}
parent
+-- child1
| ^
| |
+-- child2{code}
!image-2021-04-20-12-24-46-392.png!
h2. poms outline
{code:xml}
<project>
<!-- only relevant elements shown -->
<artifactId>parent</artifactId>
<modules>
<module>child1</module>
<module>child2</module>
</modules>
</project>
{code}
{code:xml}
<project>
<parent>
<artifactId>parent</artifactId>
</parent>
<artifactId>child1</artifactId>
</project>
{code}
{code:xml}
<project>
<parent>
<artifactId>parent</artifactId>
</parent>
<artifactId>child2</artifactId>
<dependencies>
<dependency>
<artifactId>child1</artifactId>
<scope>provided</scope>
</dependency>
<!-- other deps -->
</dependencies>
</project>
{code}
h2. Steps to reproduce
# {{mvn -pl child2 -am clean dependency:copy-dependencies -DincludeScope=runtime}}
h2. Current
{noformat}
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] parent [pom]
[INFO] child1 [jar]
[INFO] child2 [jar]
[INFO]
[INFO] -------------------------< org.example:parent >-------------------------
[INFO] Building parent 1.0.0-SNAPSHOT [1/3]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ parent ---
[INFO]
[INFO] --- maven-dependency-plugin:2.8:copy-dependencies (default-cli) @ parent ---
[INFO]
[INFO] -------------------------< org.example:child1 >-------------------------
[INFO] Building child1 1.0-SNAPSHOT [2/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ child1 ---
[INFO]
[INFO] --- maven-dependency-plugin:2.8:copy-dependencies (default-cli) @ child1 ---
[INFO]
[INFO] -------------------------< org.example:child2 >-------------------------
[INFO] Building child2 1.0-SNAPSHOT [3/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent 1.0.0-SNAPSHOT .............................. SUCCESS [ 0.744 s]
[INFO] child1 1.0-SNAPSHOT ................................ SUCCESS [ 0.043 s]
[INFO] child2 1.0-SNAPSHOT ................................ FAILURE [ 0.053 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.178 s
[INFO] Finished at: 2021-04-20T12:47:16+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project child2: Could not resolve dependencies for project org.example:child2:jar:1.0-SNAPSHOT: Failure to find org.example:child1:jar:1.0-SNAPSHOT in https://nexus.tik.uni-stuttgart.de/repository/maven-central was cached in the local repository, resolution will not be reattempted until the update interval of tik-mirror-central has elapsed or updates are forced -> [Help 1]
{noformat}
h2. Expected
{{child2}} dependencies are copied to {{child2/target/dependency}}
h2. Workaround
Forcing the installation of maven artifacts allows the plugin to resolve the depedencies (Note: I have removed many uninteresting lines from the output):
{noformat}
mvn -pl child2 -am clean install dependency:copy-dependencies -DincludeScope=runtime
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] parent [pom]
[INFO] child1 [jar]
[INFO] child2 [jar]
[INFO]
[INFO] -------------------------< org.example:parent >-------------------------
[INFO] Building parent 1.0.0-SNAPSHOT [1/3]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ parent ---
[INFO] --- maven-install-plugin:2.4:install (default-install) @ parent ---
[INFO] --- maven-dependency-plugin:2.8:copy-dependencies (default-cli) @ parent ---
[INFO]
[INFO] -------------------------< org.example:child1 >-------------------------
[INFO] Building child1 1.0-SNAPSHOT [2/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ child1 ---
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ child1 ---
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ child1 ---
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ child1 ---
[INFO] Building jar: /home/alberto/src-local/mvn-copy-deps/child1/target/child1-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ child1 ---
[INFO] Installing /home/alberto/src-local/mvn-copy-deps/child1/target/child1-1.0-SNAPSHOT.jar to /home/alberto/.m2/repository/org/example/child1/1.0-SNAPSHOT/child1-1.0-SNAPSHOT.jar
[INFO] Installing /home/alberto/src-local/mvn-copy-deps/child1/pom.xml to /home/alberto/.m2/repository/org/example/child1/1.0-SNAPSHOT/child1-1.0-SNAPSHOT.pom
[INFO]
[INFO] --- maven-dependency-plugin:2.8:copy-dependencies (default-cli) @ child1 ---
[INFO]
[INFO] -------------------------< org.example:child2 >-------------------------
[INFO] Building child2 1.0-SNAPSHOT [3/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ child2 ---
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ child2 ---
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ child2 ---
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ child2 ---
[INFO] Building jar: /home/alberto/src-local/mvn-copy-deps/child2/target/child2-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ child2 ---
[INFO] Installing /home/alberto/src-local/mvn-copy-deps/child2/target/child2-1.0-SNAPSHOT.jar to /home/alberto/.m2/repository/org/example/child2/1.0-SNAPSHOT/child2-1.0-SNAPSHOT.jar
[INFO] Installing /home/alberto/src-local/mvn-copy-deps/child2/pom.xml to /home/alberto/.m2/repository/org/example/child2/1.0-SNAPSHOT/child2-1.0-SNAPSHOT.pom
[INFO]
[INFO] --- maven-dependency-plugin:3.1.2:copy-dependencies (default-cli) @ child2 ---
[INFO] Copying jcaptcha-1.0.jar to /home/alberto/src-local/mvn-copy-deps/child2/target/dependency/jcaptcha-1.0.jar
[INFO] Copying jcaptcha-api-1.0.jar to /home/alberto/src-local/mvn-copy-deps/child2/target/dependency/jcaptcha-api-1.0.jar
[INFO] Copying imaging-01012005.jar to /home/alberto/src-local/mvn-copy-deps/child2/target/dependency/imaging-01012005.jar
[INFO] Copying commons-logging-1.0.4.jar to /home/alberto/src-local/mvn-copy-deps/child2/target/dependency/commons-logging-1.0.4.jar
[INFO] Copying commons-collections-3.2.jar to /home/alberto/src-local/mvn-copy-deps/child2/target/dependency/commons-collections-3.2.jar
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent 1.0.0-SNAPSHOT .............................. SUCCESS [ 0.775 s]
[INFO] child1 1.0-SNAPSHOT ................................ SUCCESS [ 0.939 s]
[INFO] child2 1.0-SNAPSHOT ................................ SUCCESS [ 0.689 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.752 s
[INFO] Finished at: 2021-04-20T12:50:13+02:00
[INFO] ------------------------------------------------------------------------
{noformat}
h2. Additional info
The goal {{dependency:collect}} works properly because it doesn't download the actual artifacts:
{noformat}
mvn -pl child2 -am clean dependency:collect -DincludeScope=runtime
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] parent [pom]
[INFO] child1 [jar]
[INFO] child2 [jar]
[INFO]
[INFO] -------------------------< org.example:parent >-------------------------
[INFO] Building parent 1.0.0-SNAPSHOT [1/3]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ parent ---
[INFO]
[INFO] --- maven-dependency-plugin:3.1.2:collect (default-cli) @ parent ---
[INFO]
[INFO] The following files have been resolved:
[INFO] none
[INFO]
[INFO]
[INFO] -------------------------< org.example:child1 >-------------------------
[INFO] Building child1 1.0-SNAPSHOT [2/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ child1 ---
[INFO]
[INFO] --- maven-dependency-plugin:3.1.2:collect (default-cli) @ child1 ---
[INFO]
[INFO] The following files have been resolved:
[INFO] none
[INFO]
[INFO]
[INFO] -------------------------< org.example:child2 >-------------------------
[INFO] Building child2 1.0-SNAPSHOT [3/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ child2 ---
[INFO] Deleting /home/alberto/src-local/mvn-copy-deps/child2/target
[INFO]
[INFO] --- maven-dependency-plugin:3.1.2:collect (default-cli) @ child2 ---
[INFO]
[INFO] The following files have been resolved:
[INFO] com.octo.captcha:jcaptcha:jar:1.0:compile
[INFO] com.octo.captcha:jcaptcha-api:jar:1.0:compile
[INFO] com.jhlabs:imaging:jar:01012005:compile
[INFO] commons-logging:commons-logging:jar:1.0.4:compile
[INFO] commons-collections:commons-collections:jar:3.2:compile
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent 1.0.0-SNAPSHOT .............................. SUCCESS [ 0.723 s]
[INFO] child1 1.0-SNAPSHOT ................................ SUCCESS [ 0.024 s]
[INFO] child2 1.0-SNAPSHOT ................................ SUCCESS [ 0.032 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.136 s
[INFO] Finished at: 2021-04-20T13:03:52+02:00
[INFO] ------------------------------------------------------------------------
{noformat}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)