I have a multi-module Maven project:
main-application
additional-module
- depends on main-application
I'm using maven-jar-plugin
to compile additional JAR files during when main-application
is built, based on the contents of some directory:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>additional-jar</id>
<phase>test-compile</phase>
<goals>
<goal>test-jar</goal>
</goals>
<configuration>
<testClassesDirectory>${project.build.directory}/extra-classes-input</testClassesDirectory>
<outputDirectory>${project.build.directory}/extra-classes-output</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
When I clean test-compile
the project, I get a compilation error in additional-module
, where it can't find any of the test-scoped classes in main-application
:
package com.main.application
does not existcannot find symbol
in additional-module
's test classes referencing anything from main-application
's testsMore specifically, the testClassesDirectory
property of maven-jar-plugin
is the inflection point between compilation failing and succeeding:
I'm trying to compile an additional JAR containing code from extra-classes-input
, but it looks instead I'm amending the test classes that additional-module
is trying to access.
I don't want any of the contents of the extra-JAR on the classpath so I can't add additional modules for the JAR I want to build.
What could I be doing wrong?
Because I was not specifying different classifier
s, the outputs were overwriting each other - there was a warning I missed to that effect.