My situation is pretty much the same than the one exposed in this issue except that the proposed solution using -DincludeScope=runtime
doesn't work for me :
- I build jar
- I want to copy the dependency in a folder for running the application. In this folder, I don't need the tests related classes/libraries.
- (but out of scope here) I build an archive file (.war) for deploying purpose. This archive does not contain the tests libraries.
My pom looks like :
<dependencies>
<dependency>
<groupId>my.company.group</groupId>
<artifactId>common</artifactId>
<version>4.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>my.company.group</groupId>
<artifactId>common</artifactId>
<version>4.0.0-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
As you may notice, we are using a common project providing generic classes for this project (among others). The issue has rise recently when putting generic test classes in this project and therefore creating the need of a second jar archive for test purpose. In my opinion, it should work like a charm : both jar files have different names and scope.
Creating a .war archive through mvn clean compile
is fine : the created war archive does not contain the test lib.
But copying the dependencies with mvn clean compile dependency:copy-dependencies -DoutputDirectory=./libPath -DincludeScope=runtime jar:jar
seems to not taking the scope into account. As pointed out in some other posts, the param -DexcludeScope=test
is useless as it exclude every scope.
I also tried to use the classifier
attribute on the dependency declaration and -DexcludeClassifiers=test
when running maven without notable effect.
Is there something that I'm missing, either in my mave call or my pom config ?
(Fyi : maven version is 3.0.5, running on java 7)