mvn
package in a Java Project, Maven binds plugin goals to lifecycle phases as shown in the next figure.
mvn
help:describe -Dcmd=<phase> is a very useful command not only to list the lifecycle phases but also to know the binded goal and plugin version. Run the following command from the project directory that contains the pom.xml.$ mvn help:describe -Dcmd=clean
[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
clean with
argument -Dcmd.
The help:describe validates the pom.xml and based
on project type outputs the sequence of lifecycle phases that will be executed for the lifecycle and plugin goals bounded to each phase. As we can see in the screenshot, no goals are bounded to pre-clean and post-clean phases
and they are indicated as not defined and for clean phase, clean:clean goal
of maven-clean-plugin (version 2.5) is attached.$ mvn help:describe -Dcmd=deploy
It is a part of the lifecycle for the POM packaging ‘jar’.
This lifecycle includes the following phases:
* validate: Not defined
* initialize: Not defined
* generate-sources: Not defined
* process-sources: Not defined
* generate-resources: Not defined
* process-resources: org.apache.maven.plugins:maven-resources-plugin:2.6:resources
* compile: org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
* process-classes: Not defined
* generate-test-sources: Not defined
* process-test-sources: Not defined
* generate-test-resources: Not defined
* process-test-resources: org.apache.maven.plugins:maven-resources-plugin:2.6:testResources
* test-compile: org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile
* process-test-classes: Not defined
* test: org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test
* prepare-package: Not defined
* package: org.apache.maven.plugins:maven-jar-plugin:2.4:jar
* pre-integration-test: Not defined
* integration-test: Not defined
* post-integration-test: Not defined
* verify: Not defined
* install: org.apache.maven.plugins:maven-install-plugin:2.4:install
* deploy: org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy
-
Maven comes with three lifecycles – default, clean and site.
-
each lifecycle is made up of lifecycle phases and in all, there are 28 phases – default 21, clean 3 and site 4.
-
when a lifecycle phase is invoked using mvn command, all preceding phases are executed sequentially one after another.
-
lifecycle phases by themselves doesn’t have any capabilities to accomplish some task and they rely on plugins to carryout the task.
-
depending on project and packaging type, Maven binds various plugin goals to lifecycle phases and goals carryout the task entrusted to them.
本文介绍了Maven中生命周期阶段与插件目标之间的联系,解释了如何通过命令行调用特定阶段并查看绑定的插件及其版本。根据不同类型的项目,Maven会自动绑定不同的插件目标到相应的生命周期阶段。
1060

被折叠的 条评论
为什么被折叠?



