The correct way of doing this:
- Install "abc" project into your local Maven repository by running
mvn install
inside "abc" folder. (This will build the project first, then copy the JAR and the POM into your local Maven repository.)
- And adding it as a dependency in "xyz" project:
<dependencies>
<dependency>
<groupId>...</groupId>
<artifactId>abc</artifactId>
<version>...</version>
</dependency>
</dependencies>
This way, "xyz" project will have "abc" and "abc"'s dependecies too on the classpath.
Edit: reusing test classes can be done this way:
- Add
maven-jar-plugin
to build plugins with test-jar
goal in "abc", which creates a JAR of your test classes:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
- Install "abc" (will install regular JAR, test JAR and POM)
- Add as dependency and reference the
test-jar
classifier:
<dependencies>
<dependency>
<groupId>...</groupId>
<artifactId>abc</artifactId>
<version>...</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>