How can I build a jar (with maven) which contains the test classes and the test dependencies.
I know how to create a jar with dependencies (using the assembly plugin) for the classes and dependencies for the 'main' classes but I need the test classes and test dependencies.
I know I can use the jar plugin to create a jar with test classes but this doesn't contain the test dependencies.
TIA
You can probably achieve by combining the maven-dependency-plugin:copyDependencies with the assembly plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>process-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration> <!-- by default all scopes are included -->
<!-- copy all deps to target/lib -->
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
...
</plugin>
Your descriptor:
<assembly>
<fileSets>
<fileSet>
<directory>${project.build.directory}/lib</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*.*</include>
</includes>
</fileSet>
</fileSets>
</assembly>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With