Uploaded image for project: 'Maven Shade Plugin'
  1. Maven Shade Plugin
  2. MSHADE-267

Transitive dependencies of test dependencies included in shaded jar

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.1, 3.1.0
    • None
    • None

    Description

      My project includes a test dependency to org.testng:testng, which has a bunch of compile and test dependencies:

      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
      

      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 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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jens.b Jens Bannmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: