简体   繁体   English

从反应堆级别运行时出现 Maven 执行器问题

[英]Maven enforcer issue when running from reactor level

Maven version used: 3.5.2, 3.5.3使用的 Maven 版本: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.但是从模块级别运行 mvn clean 包时工作正常。 Thats the only warning message in the trace causing the enforcer to fail the package build.这是跟踪中导致执行器无法构建包的唯一警告消息。

It's a very old reported bug but nobody seems to do anything about it: https://issues.apache.org/jira/browse/MENFORCER-189这是一个非常古老的报告错误,但似乎没有人对此采取任何措施: 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.根本原因是它将在 -pl 参数中传递的项目的 artifactid(模块名称)与其父级的 artifactid(反应器)进行比较。 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)对我们来说,修复是在使用此执行时禁用执行器插件(其他没有 -pl 的执行,如“全新安装”也可以)

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

Try including --also-make or -am , for example:尝试包括--also-make-am ,例如:

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

Even if the module you're building doesn't have a dependency on another module within the build, this triggers a Reactor build that includes the given module and the parent POM together, and their relationship is then able to be verified by Enforcer without skipping.即使您正在构建的模块不依赖于构建中的另一个模块,这也会触发一个包含给定模块和父 POM 的 Reactor 构建,然后它们的关系可以由 Enforcer 验证而不会跳过. (Works with Maven 3.6.2 in my case). (在我的情况下与 Maven 3.6.2 一起使用)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM