Skip to content

Instantly share code, notes, and snippets.

@olamy
Created August 17, 2011 09:55
Show Gist options
  • Save olamy/1151235 to your computer and use it in GitHub Desktop.
Save olamy/1151235 to your computer and use it in GitHub Desktop.
How to create a jar containing test classes
You can produce a jar which will include your test classes and resources.
<project>
...
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
...
</project>
To reuse this artifact in an other project, you must declare this dependency with classifier test-jar :
<project>
...
<dependencies>
<dependency>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<type>test-jar</type>
<version>version</version>
</dependency>
</dependencies>
...
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment