I'm having trouble using test-jar
dependencies in a multi-module project. For example, when I declare that the cleartk-syntax
module depends on the cleartk-token
module's test-jar
like this (the full code is here):
<modelVersion>4.0.0</modelVersion>
<groupId>org.cleartk</groupId>
<artifactId>cleartk-syntax</artifactId>
<version>0.5.0-SNAPSHOT</version>
<name>cleartk-syntax</name>
...
<dependencies>
...
<dependency>
<groupId>org.cleartk</groupId>
<artifactId>cleartk-token</artifactId>
<version>0.7.0-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
I get the following error if I run mvn compile
using maven 2:
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Missing:
----------
1) org.cleartk:cleartk-token:test-jar:tests:0.7.0-SNAPSHOT
If I use maven 3 I get the error:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.654s
[INFO] Finished at: Mon Jan 24 21:19:17 CET 2011
[INFO] Final Memory: 16M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project cleartk-syntax: Could not resolve
dependencies for project org.cleartk:cleartk-syntax:jar:0.5.0-SNAPSHOT: Could
not find artifact org.cleartk:cleartk-token:jar:tests:0.7.0-SNAPSHOT
In the latter case, I'm particularly confused because I would have thought it should be looking for an artifact of type test-jar
not of type jar
.
With maven 2 or maven 3, I can get it to compile by running mvn compile package -DskipTests
. With maven 3, I can also get it to compile by running mvn compile test-compile
.
But why is either maven 2 or maven 3 looking for a test-jar
dependency during the compile
phase? Shouldn't it wait until the test-compile
phase to look for such dependencies?
Update: The answer was that the maven-exec-plugin, used during my compile phase, requires dependency resolution of artifacts in scope:test. I've created a feature request to remove the scope:test dependency.