Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude test dependencies from a shaded maven jar?

I'm using the maven-shade-plugin and I'd like to exclude not only my test code, but my test dependencies in the shaded jar. I realize I can specifically exclude certain artifacts (like junit), but that's a good bit of work and prone to some error most likely.

I'm setting minimizeJar to true, but I still see my Junit and Mockito dependencies showing up. Is there just no way to exclude all test scoped dependencies via configuration?

like image 311
AHungerArtist Avatar asked May 09 '13 16:05

AHungerArtist


1 Answers

Make sure your test dependencies in the test scope:

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
...

To check if your dependency setup use

mvn dependency:tree
like image 101
rzymek Avatar answered Sep 23 '22 01:09

rzymek