Maven-10: 使用maven-help-plugin描述插件

时间:2021-06-09 21:03:08

除了访问在线的插件文档之外,还可以借助maven-help-plugin来获取插件的详细信息。可以运行如下命令来获取maven-compiler-plugin2.1版本的信息:
Maven-10: 使用maven-help-plugin描述插件

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-help-plugin:2.2:describe (default-cli) @ standalone-pom ---
[INFO] org.apache.maven.plugins:maven-compiler-plugin:2.1 Name: Maven Compiler Plugin
Description: The Compiler Plugin is used to compile the sources of your
project.
Group Id: org.apache.maven.plugins
Artifact Id: maven-compiler-plugin
Version: 2.1
Goal Prefix: compiler This plugin has 3 goals: compiler:compile
Description: Compiles application sources compiler:help
Description: Display help information on maven-compiler-plugin.
Call
mvn compiler:help -Ddetail=true -Dgoal=<goal-name>
to display parameter details. compiler:testCompile
Description: Compiles application test sources. For more information, run 'mvn help:describe [...] -Ddetail' [INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.017 s
[INFO] Finished at: 2015-11-18T19:38:06+08:00
[INFO] Final Memory: 8M/96M
[INFO] ------------------------------------------------------------------------

这里执行的是maven-help-plugin的describe目标,在参数plugin中输入需要描述插件的groupId,artifactId和version。对于坐标和插件目标,不再多做解释。这里值得一提的是目标前缀(Goal Prefix),其作用是方便在命令行直接运行插件。maven-compiler-plugin的目标前缀是compiler。

在描述插件的时候,还可以省去版本信息,让Maven自动获取最新版本来进行表述,例如:

$ mvn help:describe -Dplugin=org.apache.maven.plugins:maven-compiler-plugin

进一步简化,可以使用插件目标前缀替换坐标:

$ mvn help:describe -Dplugin=compiler

如果想仅仅描述某个插件目标的信息,可以加上goal参数:

$ mvn help:describe -Dplugin=compiler -Dgoal=compile

如果想让maven-help-plugin输出更详细的信息,可以加上detail参数:

$ mvn help:describe -Dplugin=compiler -Ddetail