4

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

5
  • Based on the error message i would assume the dependenies within this multi-module build are not correct, cause if the dependencies are correct the build should work without any problems without installing the artifacts into local repository via mvn install Commented Mar 6, 2013 at 13:00
  • This was my first thought - but the error only occurs with my own plugin, not surefire. If the project was in someway incorrectly setup I'd expect both plugins to display the same error. Commented Mar 6, 2013 at 22:28
  • Did you read the description for @requiresDependencyCollection ? Maybe you are too early in the processing chain where actually the dependencies are not yet put onto the classpath? Commented Mar 20, 2013 at 4:43
  • Have you cleaned your local repository and tried to build the project from scratch without your plugin? Commented Sep 16, 2013 at 10:49
  • @khmarbaise Thanks for the suggestion but that wasn't it - just added an answer describing how this was resolved. Commented Sep 16, 2013 at 18:59

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.