Question

I have a mojo annotated with @requiresDependencyResolution test.

It works for multi-module projects with a single layer of nesting, but a user has reported an issue with a structure such as below.

 -- my_project
    |
    -- pom.xml
    -- submodule1
       |
       -- pom.xml
    -- submodule2
       |
       -- pom.xml
       -- submodule21
         |
         -- pom.xml
       -- submodule22
         |
         -- pom.xml

If submodule21 depends on submodule1 maven reports

Failed to execute goal on project submodule21: Could not resolve dependencies for project org.my:submodule21:jar:1.0-SNAPSHOT: Could not find artifact org.my:submodule1:jar:1.0-SNAPSHOT

Removing the requiresDependencyResolution=test annotation prevents this problem but then I do not have access to the information I require for the mojo to run.

From brief scan of the surefire code on github, it looks to also use requiresDependencyResolution=test but is able to run against this project without issue.

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 rather than old style javadoc ones.

How is the surefire mojo achieving this?

My code is

http://code.google.com/p/pitestrunner/source/browse/pitest-maven/src/main/java/org/pitest/maven/PitMojo.java

Example project displaying issue

http://code.google.com/p/pitestrunner/issues/detail?id=71

Was it helpful?

Solution

For the benefit of anyone else having this issue - I eventually solved this problem. There was no issue with the plugin.

The difference between surefire and my own plugin was simply the way in which they were being run. Surefire was bound to the test phase, my own plugin was being run by calling a goal directly. When I bind my plugin to the verify phase, everything resolves without issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top