Hi,
I have a multi-module-project with one module that implements classes for
testing (test-parent) and another module (test-child) that uses theses classes.
There is a dependency in test scope from the test-child to the test-parent.
(See article
http://stackoverflow.com/questions/1725476/maven-test-dependency-in-multi-module-project
and
http://maven.apache.org/guides/mini/guide-attached-tests.html[http://maven.apache.org/guides/mini/guide-attached-tests.html])
The pom of the depending test-child contains the following code:
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>test-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
The test-parent module that contains the derived classes contains the following
code:
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
<phase>test-compile</phase>
</execution>
</executions>
</plugin>
</plugins>
In a parent pom the maven-enforcer-plugin is included and the
RequireReleaseDeps rule is added to the list of rules. While running the Maven
goal “compile” the project compilation of the test-child fails with the
following message:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (default) on
project test-child: Execution default of goal
org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce failed:
org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException: Could
not resolve dependencies for project test:test-child:jar:1.0.0: Failure to find
test:test-parent:jar:tests:1.0.0
It seems that Maven checks the dependencies of type and scope “test” in the
compile phase. In the case the test-jar is build in the test-compile and is not
present yet. This leads to the error.
If I remove the RequireReleaseDeps from the rules it works fine.
Here is the simplified config of the maven-enforcer-plugin:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${maven-enforcer-plugin.version}</version>
<inherited>true</inherited>
<executions>
<execution>
<goals><goal>enforce</goal></goals>
</execution>
</executions>
<configuration>
<!-- <skip/> -->
<rules>
<requireReleaseDeps>
<onlyWhenRelease>false</onlyWhenRelease>
</requireReleaseDeps>
<requireMavenVersion>
<version>[3.0.4,]</version>
</requireMavenVersion>
</rules>
<fail>${maven-enforcer-plugin.fail}</fail>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
</plugin>
</plugins>
</build>
Is this behavior of the maven-enforcer-plug-in correct? If so, is there a way
to work around it?
Matthias
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]