The project I'm working on is made of multiple modules, being built with maven. The test code in some modules has dependencies on test code from other modules. These dependencies are declared as below.
In the dependency module:
<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>
In the module which has the dependency on the previous module:
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>themodulename</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
Using this configuration, the maven install phase can be executed successfully. But trying to run the compile or test phase fails, because the test jar file dependency cannot be resolved.
Looking at the test-jar goal, it seems to be configured to run by default during the package phase, which I think is the cause of the problem.
Then, I tried to force this goal to run during the compile phase, by modifying the first config into:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
Looking at the debug logs, I can see that the goal is now executed during the compile phase, but also this:
[WARNING] JAR will be empty - no content was marked for inclusion!
I tried to configure the includes to **/* and confirmed that the default testClassesDirectory was set to the right one, but I still get the same warning.
I could see that the test-classes folder didn't exist after running the compile phase, which seems normal, but even though it exists after running the test phase, and it contains files, I still get the "JAR will be empty" warning.
Does anyone have any idea on fixing this configuration so that I can run successfully the compile or test phase?