Jens Bannmann created MSHADE-267:
------------------------------------
Summary: Transitive dependencies of test dependencies included in
shaded jar
Key: MSHADE-267
URL: https://issues.apache.org/jira/browse/MSHADE-267
Project: Maven Shade Plugin
Issue Type: Bug
Affects Versions: 3.1.0, 2.1
Reporter: Jens Bannmann
My project includes a {{test}} dependency to {{org.testng:testng}}, which has a
bunch of {{compile}} and {{test}} dependencies:
{code}
com.github.elgashu:elgashu:jar:0.2-SNAPSHOT
+- org.testng:testng:jar:6.8:test
+- junit:junit:jar:4.10:compile
| \- org.hamcrest:hamcrest-core:jar:1.1:compile
+- org.beanshell:bsh:jar:2.0b4:test
+- com.beust:jcommander:jar:1.27:test
\- org.yaml:snakeyaml:jar:1.6:test
{code}
I use the Shade plugin to create a fat jar of my production code; I want
neither my test code nor its dependencies to end up in that fat jar.
However, while the Shade plugin correctly excludes {{org.testng:testng}} itself
(due to the {{test}} scope), its {{compile}} dependencies ({{junit:junit:jar}}
and {{org.hamcrest:hamcrest-core}}) also end up in the shaded jar. This
contradicts [Maven's rules for transitive dependency
scoping|https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope]
which say that {{compile}} dependencies of {{test}} dependencies turn into
{{test}} as well.
The workaround would be to explicitly exclude each of those transitive
dependencies (and their transitive dependencies), but that effectively means
manually tracking the dependency trees of all upstream dependencies, which IMO
is not feasible.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)