[英]versions:display-plugin-updates does not understand maven-enforcer-plugin
So, I'm trying to use the latest version of some plugins. 所以,我正在尝试使用最新版本的一些插件。 Earlier I've used the prerequisites-tag but lots of resources ( example ) say that it should be considered deprecated and that the maven-enforcer-plugin should be used instead.
之前我已经使用了先决条件标签,但是很多资源( 例子 )说它应该被认为是弃用的,而且应该使用maven-enforcer-plugin。 this is my configuration:
这是我的配置:
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<id>enforce-maven-3</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.0.4</version>
</requireMavenVersion>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
However, when I run mvn versions:display-plugin-updates I still get this text: 但是,当我运行mvn版本时:display-plugin-updates我仍然得到这个文本:
[ERROR] Project does not define required minimum version of Maven.
[ERROR] Update the pom.xml to contain
[ERROR] <prerequisites>
[ERROR] <maven>3.0</maven>
[ERROR] </prerequisites>
[INFO]
[INFO] Require Maven 2.0.6 to use the following plugin updates:
[INFO] maven-jar-plugin ................................................ 2.4
[INFO] maven-shade-plugin ............................................ 1.7.1
[INFO]
[INFO] Require Maven 2.2.1 to use the following plugin updates:
[INFO] maven-jar-plugin ................................................ 2.6
[INFO]
[INFO] Require Maven 3.0 to use the following plugin updates:
[INFO] maven-shade-plugin .............................................. 2.3
Using the prerequisites-tag instead works. 使用先决条件标签代替工作。
It seems like this issue has been reported here (credits go to Aleksandr M for finding this). 看来这个问题已经在这里报道了 (为了找到这个,可以去Aleksandr M )。
Apparently, the display-dependency-updates goal relies on the prerequisites
element to find out the Maven version required by the current project and totally ignores the enforcer-plugin, even though the prerequisites-tag should not be used normally, it is required in order to get the dependency plugin to behave as expected. 显然, display-dependency-updates目标依赖于
prerequisites
元素来找出当前项目所需的Maven版本并完全忽略enforcer-plugin,即使不能正常使用prerequisites-tag,也需要按顺序让依赖插件按预期运行。
To avoid this message I use last version of versions-maven-plugin 为了避免这个消息,我使用了版本的maven-plugin的最新版本
mvn org.codehaus.mojo:versions-maven-plugin:2.7:display-plugin-updates
Note that it still requires either use of maven-enforcer-plugin for all but maven-plugin
projects, or use of prerequisites
tag for projects with maven-plugin
packaging. 请注意,除了
maven-plugin
项目之外,还需要使用maven-enforcer-plugin ,或者对maven-plugin
打包的项目使用prerequisites
标记。
The prerequisites is deprecated for Maven 3.X: Maven 3.X已弃用先决条件:
http://jira.codehaus.org/browse/MNG-4840 http://jira.codehaus.org/browse/MNG-5297 http://jira.codehaus.org/browse/MNG-4840 http://jira.codehaus.org/browse/MNG-5297
Furthermore if you call 如果你打电话
mvn versions:display-plugin-updates
you are not starting a life cycle whereas the configuration of your maven-enforcer-plugin is bound to the life cycle. 您没有开始生命周期,而maven-enforcer-plugin的配置与生命周期绑定。
Furthermore you should pin all versions of the plugins you are using in your build. 此外,您应该固定您在构建中使用的所有插件版本。
And one very important things (excerpt from the FAQ): 还有一件非常重要的事情(摘自常见问题解答):
The prerequisites tag was designed to be used by tools like plugins.
先决条件标记旨在供插件等工具使用。 It will work for regular projects, but it isn't inherited to their children.
它适用于常规项目,但不会遗传给他们的孩子。 If it is set in a parent reactor, then Maven will do the check.
如果它在父反应堆中设置,那么Maven将进行检查。 However if one of the children are built, the check is not performed.
但是,如果构建其中一个子项,则不执行检查。 The enforcer plugin is designed to allow centralized control over the build environment from a single "super-pom", and to allow greater flexibility in version specification by supporting ranges.
enforcer插件旨在允许从单个“super-pom”集中控制构建环境,并通过支持范围允许更大的版本规范灵活性。
This means only if your developing plugins the prerequisites does make a limited sense better to use the maven-enforcer-plugin path. 这意味着只有在您的开发插件中,先决条件才能更好地使用maven-enforcer-plugin路径。 For usual development project use the maven-enforcer-plugin configuration way to force particular Maven versions.
对于通常的开发项目,使用maven-enforcer-plugin配置方式强制使用特定的Maven版本。
To stay informed about plugin update i can recommend to subscribe to the Announcment mailing list or if you like to get a good overview see the plugins page . 要了解有关插件更新的信息,我建议您订阅Announcment邮件列表,或者如果您想获得一个好的概述,请参阅插件页面 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.