Reputation: 2882
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] ------------------------------------------------------------------------
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
.
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
.
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
As you can see, the pom doesnt seem to define alias. So following are my questions
Upvotes: 4
Views: 1844
Reputation: 27852
From official Maven documentation about plugins development:
Shortening the Command Line
There are several ways to reduce the amount of required typing:
- If you need to run the latest version of a plugin installed in your local repository, you can omit its version number. So just use
mvn sample.plugin:hello-maven-plugin:sayhi
to run your plugin.- You can assign a shortened prefix to your plugin, such as
mvn hello:sayhi
. This is done automatically if you follow the convention of using${prefix}-maven-plugin
(ormaven-${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.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
${user.home}/.m2/settings.xml
file:
<pluginGroups> <pluginGroup>sample.plugin</pluginGroup>
</pluginGroups>
At this point, you can run the mojo with
mvn hello:sayhi
.
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.
Upvotes: 9