A test jar is a jar file used to share test code between module.
In two steps:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<dependency>
<groupId>group-id</groupId>
<artifactId>module1</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
Using
testsinstead of
test-jarwill not work during a reactor build of the test JAR module and any consumer if a lifecycle phase prior to install is invoked. In such a scenario, Maven will not resolve the test JAR from the output of the reactor build but from the local/remote repository.