Hi,
based on the error message you have a dependency on your test-jar
project but you defined the dependency a little bit wrong:
test:test-child:jar:1.0.0: Failure to find test:test-parent:jar:tests:1.0.0
This shows that you have defined a dependency in the test-parent but
like this:
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>test-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
BUT you have to give the type in this case like this:
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>test-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
Best test is to comment out the maven-enforcer-rule and try to build
your project just from the parent via
mvn clean package
I assume in your case without the above fix your project will not build.
If it will you need to clean out your local repository first and retry it...
Kind regards
Karl Heinz Marbaise
> 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>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org