[ https://issues.apache.org/jira/browse/MDEP-687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17101019#comment-17101019 ]
John Lin commented on MDEP-687: ------------------------------- I executed {{mvn dependency:tree}} against your example pom, and here is the result: {code} $ mvn dependency:tree [INFO] Scanning for projects... [INFO] [INFO] ---------------------------< test:pom-test >---------------------------- [INFO] Building pom-test 0.1 [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-dependency-plugin:3.1.2:tree (default-cli) @ pom-test --- [INFO] test:pom-test:jar:0.1 [INFO] +- ch.qos.logback:logback-access:jar:1.2.2:compile [INFO] +- ch.qos.logback:logback-core:jar:1.2.2:test [INFO] \- org.slf4j:slf4j-api:jar:1.7.25:test [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.930 s [INFO] Finished at: 2020-05-07T01:08:24+08:00 [INFO] ------------------------------------------------------------------------ {code} It seems that {{logback-core}} is treated as {{test}} scope in the first place. I think it's because of the dependency mediation. You can find more details at https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html. > includeScope=runtime for copy-dependencies does not include transitive > compile-time dependencies > ------------------------------------------------------------------------------------------------ > > Key: MDEP-687 > URL: https://issues.apache.org/jira/browse/MDEP-687 > Project: Maven Dependency Plugin > Issue Type: Bug > Reporter: Dmitry Andrianov > Priority: Major > > We using {{copy-dependencies}} from dependency plugin to collect all the > libraries needed by the application at runtime into a {{lib/}} directory. We > obviously do not want to include any test dependencies so we are setting > {code:xml} > <includeScope>runtime</includeScope>{code} > It normally works as expected except for one case. Imagine:: > {code:java} > application > | > + libOne (test) > | > + libTwo (compile) > | > + libOne (compile) > {code} > With this layout our application only needs {{libOne}} during tests but at > the same time we depend on {{libTwo}} which in turn depends on {{libOne}}. In > the end {{libOne}} is required for the application to function. Unfortunately > it gets excluded by {{copy-dependencies}} with {{scope=runtime}}. This is a > nasty surprise given the documentation > [https://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html#includeScope] > says > {quote}The scopes being interpreted are the scopes as Maven sees them, not as > specified in the pom. > {quote} > Surely, Maven should see {{libOne}} as a runtime thing when resolving > dependencies... > Below is a full POM that reproduces the case (with arbitrary libraries > though). > We have {{logback-access}} as compile dependency and it should bring > {{logback-core}} with it but because we also declare {{logback-core}} as a > test dependency for the application - it gets demoted to test only and not > included into {{lib/}} directory. > {code:xml} > <?xml version="1.0" encoding="UTF-8"?> > <project xmlns="http://maven.apache.org/POM/4.0.0" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 > http://maven.apache.org/maven-v4_0_0.xsd"> > <modelVersion>4.0.0</modelVersion> > <groupId>test</groupId> > <artifactId>pom-test</artifactId> > <version>0.1</version> > <packaging>jar</packaging> > <build> > <plugins> > <plugin> > <groupId>org.apache.maven.plugins</groupId> > <artifactId>maven-compiler-plugin</artifactId> > <version>3.1</version> > </plugin> > <plugin> > <groupId>org.apache.maven.plugins</groupId> > <artifactId>maven-dependency-plugin</artifactId> > <version>3.1.2</version> > <executions> > <execution> > <id>copy-dependencies</id> > <phase>package</phase> > <goals> > <goal>copy-dependencies</goal> > </goals> > <configuration> > > <outputDirectory>${project.build.directory}/lib</outputDirectory> > <!-- what we trying to do here is to not include > any dependencies that are > needed for testing ONLY into our "final" > lib/ directory --> > <includeScope>runtime</includeScope> > </configuration> > </execution> > </executions> > </plugin> > </plugins> > </build> > <dependencies> > <dependency> > <groupId>ch.qos.logback</groupId> > <artifactId>logback-access</artifactId> > <version>1.2.2</version> > </dependency> > <dependency> > <groupId>ch.qos.logback</groupId> > <artifactId>logback-core</artifactId> > <version>1.2.2</version> > <!-- logback-access has a 'compile' dependency to logback-core > --> > <!-- what we trying to say here is that for our test module, we > only need it as 'test' --> > <!-- however it should still end as a runtime scope because > needed by logback-access! --> > <scope>test</scope> > </dependency> > <dependency> > <groupId>org.slf4j</groupId> > <artifactId>slf4j-api</artifactId> > <version>1.7.25</version> > <!-- This one is also a test-time dependency and should not end > up in the lib/ because nothing > brings it as compile/runtime --> > <scope>test</scope> > </dependency> > </dependencies> > </project>{code} > -- This message was sent by Atlassian Jira (v8.3.4#803005)