如何在项目中查找 Maven 插件的版本?

How to find the version of a Maven plugin in the project?

我正在尝试查找我的项目中使用的 maven-wagon 插件的版本。有没有办法通过命令行找到所用插件的版本?

有几种方法可以做到这一点:

1) 检查依赖树:

要找出您正在使用的库和版本,您可以使用 Maven dependency tree,只需在您的项目所在的位置执行此命令 (pom.xml) :

mvn dependency:tree -Dverbose

这对于检测您的项目正在使用的特定库的哪个版本很有用,但我认为它不包括插件。

2) 描述具体插件:

如果您想知道您安装的特定插件的版本,您可以这样做:

mvn -Dplugin=: help:describe

mvn -Dplugin=org.codehaus.mojo:wagon-maven-plugin help:describe

这表明你是这样的:

Name: Maven Wagon plugin
Description: Maven plugin that can be used to access various operations on a
  given URL using a supported maven wagon. Supports recursive upload, download,
  and list directory content functionality.
Group Id: org.codehaus.mojo
Artifact Id: wagon-maven-plugin
Version: 1.0
Goal Prefix: wagon
 
This plugin has 11 goals:
...
...

3) 检查有效pom:

执行这个:

mvn help:effective-pom

然后通过 pom 寻找你需要澄清的插件,在那里你会发现这样的东西:

<plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>wagon-maven-plugin</artifactId>
   <version>1.0</version>
</plugin>