I have doubts about what you are trying to do, but I assume that you want to reuse the tests you created for the project (module1) in another. As explained in the note below the Guide to Using Connected Tests :
Note that in previous releases of this guide, it was suggested that you use <classifier>tests</classifier> instead of <type>test-jar</type> . Although this currently works in some cases, it does not work properly during assembly of the JAR module reactor and any consumer if the life cycle phase before installation is involved. In this case, Maven will not allow the test JAR from the output of the reactor assembly, but from the local / remote repository. Apparently, the JARs from the repositories may be outdated or completely absent, causing build failures (see MNG-2045 ).
So, firstly, to pack the compiled tests in the JAR and deploy them for general reuse, configure the maven-jar-plugin as follows:
<project> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.2</version> <executions> <execution> <goals> <goal>test-jar</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
Then install / deploy the test JAR artifact as usual (using mvn install or mvn deploy ).
Finally, to use the test JAR, you must specify a dependency with the specified type test-jar :
<project> ... <dependencies> <dependency> <groupId>com.myco.app</groupId> <artifactId>foo</artifactId> <version>1.0-SNAPSHOT</version> <type>test-jar</type> <scope>test</scope> </dependency> </dependencies> ... </project>
Pascal Thivent Nov 14 '09 at 9:02 2009-11-14 09:02
source share