maven-2 - Maven 插件更新

标签 maven-2

是否有自动跟踪 maven 插件版本更新的机制。由于大多数时候在dependencyManagement 中,您对每个插件的版本号进行了硬连线。是否有管理命令来查找有关 pom.xml 中声明的插件可用的较新版本的信息?

最佳答案

Versions Maven Plugin有一个不错的 versions:display-plugin-updates 为此,魔力。
要使用它,只需运行:

mvn versions:display-plugin-updates

这会产生类似的东西:
[INFO] ------------------------------------------------------------------------
[INFO] Building sandbox
[INFO]    task-segment: [versions:display-plugin-updates]
[INFO] ------------------------------------------------------------------------
[INFO] [versions:display-plugin-updates {execution: default-cli}]
[INFO] 
[INFO] The following plugin updates are available:
[INFO]   maven-clean-plugin ....................................... 2.2 -> 2.4
[INFO]   maven-compiler-plugin .................................. 2.0.2 -> 2.1
[INFO]   maven-deploy-plugin ...................................... 2.4 -> 2.5
[INFO]   maven-install-plugin ..................................... 2.2 -> 2.3
[INFO]   maven-jar-plugin ......................................... 2.2 -> 2.3
[INFO]   maven-resources-plugin ................................. 2.3 -> 2.4.1
[INFO]   maven-site-plugin ................................. 2.0-beta-7 -> 2.1
[INFO]   maven-surefire-plugin .................................. 2.4.3 -> 2.5
[INFO] 
[INFO] All plugins have a version specified.
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Fri Jan 22 07:21:57 CET 2010
[INFO] Final Memory: 16M/68M
[INFO] ------------------------------------------------------------------------

It will also warn you if you have not specified the versions of plugins that you are using. See Checking for new plugin updates for details.

Update: (answering some additional questions posted as comments)

How does it decide to figure out the list of plugins to search for (is it from pluginManagement?)

AFAIK, the plugin should scan all plugins i.e. build.plugins, build.pluginManagement.plugins and build.reporting.plugins (see MVERSIONS-83 about this).

I did a quick check on build/pluginManagement/plugins and it looks like didn't find updates for plugins other than org.apache.maven.plugins

I did a test too and this is not what I'm observing. At least it works with mojos from codehaus (like in the last sample from the previous link). But if I move the plugin in build.plugins, it doesn't work indeed. This is actually a bug, see MVERSIONS-69. Surprisingly, it seems to work with the version 1.1 that you can run as shown below:

mvn org.codehaus.mojo:versions-maven-plugin:1.1:display-plugin-updates

如果你仔细看 MVERSIONS-69 ,集成测试的输出表明它应该适用于任何插件。但我承认,我不是 100% 确定。

关于maven-2 - Maven 插件更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2115328/

相关文章:

java - 在项目 xxx 的构建路径中检测到循环 - 构建路径问题

maven-2 - 如何构建重命名的 POM xml

java - 使用 Maven 在 jar 中包含依赖项

java - 线程 "main"java.lang.NoClassDefFoundError : org/apache/http/ConnectionReuseStrategy: 中的异常

java - 如何防止mvn jetty :run from executing test phase?

maven - 在 Maven 项目中查找包含类文件的 jar

java - Maven 插件记录器兼容性

maven-2 - 如何使用 Maven 2 Tomcat 插件运行 Tomcat 7?

java - 使用 Maven 分发可以单独跟踪每个依赖项的 swing 应用程序

maven-2 - 使用 maven2 编译时将 list 添加到 jar 文件