Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven enforcer issue when running from reactor level

Maven version used: 3.5.2, 3.5.3

mvn clean package -pl <root-artifact-id>:<module-name>

is failing saying

    [WARNING] Rule 3: org.apache.maven.plugins.enforcer.ReactorModuleConvergence failed with message:
Module parents have been found which could not be found in the reactor.
 module: <artifact:id>:<module-name>:war:1.0-SNAPSHOT

But working fine when running the mvn clean package from the module level though. Thats the only warning message in the trace causing the enforcer to fail the package build.

like image 568
Vishwaksena Avatar asked Jun 01 '18 15:06

Vishwaksena


1 Answers

It's a very old reported bug but nobody seems to do anything about it: https://issues.apache.org/jira/browse/MENFORCER-189

Root cause would be that it compares the artifactid (module-name) of the project passed in the -pl paramater with the artifactid (reactor) of its parent. Which would never be the same and thus will always give this error.

For us the fix was to disable the enforcer plugin when using this execution (other executions without the -pl like 'clean install' are fine)

mvn clean install
mvn package -pl module-name -Denforcer.skip=true

Edit:
Another option is to specify the reactor project in the build using '.' (note: this will also package the reactor)

mnv clean package -pl .,module-name
like image 166
Andre Haverdings Avatar answered Sep 29 '22 06:09

Andre Haverdings