Maven插件别名如何映射 [英] How are maven plugin aliases mapped
问题描述
我正在尝试了解mvn clean:clean的实际作用.
I am trying to understand what mvn clean:clean actually does.
mvn -B help:describe -Dcmd=clean
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building sample-one 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-help-plugin:2.2:describe (default-cli) @ sample-one ---
[INFO] 'clean' is a lifecycle with the following phases:
* pre-clean: Not defined
* clean: org.apache.maven.plugins:maven-clean-plugin:2.5:clean
* post-clean: Not defined
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.689 s
[INFO] Finished at: 2015-12-10T10:20:16-08:00
[INFO] Final Memory: 9M/245M
[INFO] ------------------------------------------------------------------------
在我看来,mvn clean:clean
与执行mvn org.apache.maven.plugins:maven-clean-plugin:2.5:clean
相同.因此,我假设mvn clean:clean
中的第一个clean
只是org.apache.maven.plugins:maven-clean-plugin:2.5
的别名.类似地,mvn maven-surefire-plugin:2.12.4:test
与mvn surefire:test
相同.
It appears to me that mvn clean:clean
is same as doing mvn org.apache.maven.plugins:maven-clean-plugin:2.5:clean
. Therefore I am assuming the first clean
in mvn clean:clean
is just an alias for org.apache.maven.plugins:maven-clean-plugin:2.5
. Similarly mvn maven-surefire-plugin:2.12.4:test
is same as mvn surefire:test
.
所以以某种方式,maven-surefire-plugin:2.12.4
似乎是指surefire
,而org.apache.maven.plugins:maven-clean-plugin:2.5
是指clean
.
So somehow, maven-surefire-plugin:2.12.4
seems to refer to surefire
and org.apache.maven.plugins:maven-clean-plugin:2.5
to clean
.
当我看有效的pom时,我看到以下内容 maven-surefire-插件 2.12.4 默认测试 测试 测试 maven-clean-plugin 2.5 默认清理 干净的 干净的
When I look at the effective-pom, I see the following maven-surefire-plugin 2.12.4 default-test test test maven-clean-plugin 2.5 default-clean clean clean
如您所见,pom似乎没有定义别名.所以下面是我的问题
As you can see, the pom doesnt seem to define alias. So following are my questions
- 我对插件别名的理解正确吗
- 如果我对别名的理解是正确的-a)如何以及在何处定义它们? b)有没有办法列出所有别名.
推荐答案
摘自有关
缩短命令行 Shortening the Command Line 最后,您还可以将插件的groupId添加到默认搜索的groupId列表中.为此,您需要将以下内容添加到您的 Finally, you can also add your plugin's groupId to the list of groupIds searched by default. To do this, you need to add the following to your 此时,您可以使用 At this point, you can run the mojo with 因此,别名未在pom文件中定义,而是maven内置机制的一部分.官方文档中还提供了有关插件前缀解析的更多详细信息. . So, alias are not defined in the pom file but part of built-in mechanism of maven. Further details are also provided in the official documentation about Plugin Prefix Resolution. 这篇关于Maven插件别名如何映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
有几种方法可以减少所需的键入量:
There are several ways to reduce the amount of required typing:
mvn sample.plugin:hello-maven-plugin:sayhi
运行您的插件即可.mvn hello:sayhi
.如果遵循使用${prefix}-maven-plugin
的约定(或者如果插件是Apache Maven项目的一部分,则使用maven-${prefix}-plugin
),则将自动完成此操作.您也可以通过其他配置分配一个-有关更多信息,请参见插件前缀映射简介.${user.home}/.m2/settings.xml
文件中:
mvn sample.plugin:hello-maven-plugin:sayhi
to run your plugin.mvn hello:sayhi
. This is done automatically if you follow the convention of using ${prefix}-maven-plugin
(or maven-${prefix}-plugin
if the plugin is part of the Apache Maven project). You may also assign one through additional configuration - for more information see Introduction to Plugin Prefix Mapping.${user.home}/.m2/settings.xml
file:<pluginGroups>
<pluginGroup>sample.plugin</pluginGroup>
</pluginGroups>
<pluginGroups>
<pluginGroup>sample.plugin</pluginGroup>
</pluginGroups>
mvn hello:sayhi
运行mojo.mvn hello:sayhi
.