I have a mojo annotated with the @requiresDependencyResolution test.
It works for multi-module projects with one nesting layer, but the user has reported a problem with the structure, such as below.
-- my_project | -- pom.xml -- submodule1 | -- pom.xml -- submodule2 | -- pom.xml -- submodule21 | -- pom.xml -- submodule22 | -- pom.xml
If submodule 21 depends on messages subodule1 maven
Failed to fulfill the target on the project submodule21: failed to resolve dependencies for the org.my:submodule21:jar:1-SNAPSHOT project: The org.my:submodule1:jar:1.0-SNAPSHOT artifact could not be found
Removing the invalidate requireDependencyResolution = test invalidation prevents this problem, but then I don't have access to the information I require to run mojo.
With a brief look at the code for reliable code on github, it also uses the requireDependencyResolution = test function, but it can work against this project without problems.
https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
https://github.com/apache/maven-surefire/blob/master/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
The only obvious difference from my own code is that it uses java annotations, not old style javadocs.
How is this point achieved?
My code
http://code.google.com/p/pitestrunner/source/browse/pitest-maven/src/main/java/org/pitest/maven/PitMojo.java
Project display problem example
http://code.google.com/p/pitestrunner/issues/detail?id=71
In the interest of someone else having this problem, I ended up solving this problem. There were no problems with the plugin.
The difference between surefire and my own plugin was just the way they started. Surefire was involved in the test phase, my own plugin was launched, knowing the target directly. When I bind my plugin to the verification phase, everything solves without problems.