我只是在学习Maven,所以这可能是显而易见的,但我找不到一种简单的方法来列出给定项目的每个maven生命周期阶段的相关目标。
我看到Maven默认生命周期阶段和相应的缺省目标都记录在here中。到目前为止,我的理解是,每个pom.xml可以将额外的目标绑定到每个生命周期阶段。
那么,是否有一个mvn命令来确定将为给定项目的每个生命周期阶段运行的目标?如果不是,我想我只需要查看每个新的maven项目的pom.xml就可以解决这个问题了。
发布于 2010-01-15 01:31:09
mvn help:describe -Dcmd=compile
(或任何其他有效阶段)
发布于 2016-02-25 02:41:49
buildplan-maven-plugin
是一个很好的工具,用于显示目标是如何绑定到阶段的。
下面是您可以运行的命令示例。如果插件尚未安装,这些命令将自动下载并安装该插件。
按目标执行的顺序列出目标
> mvn fr.jcgay.maven.plugins:buildplan-maven-plugin:list
PLUGIN | PHASE | ID | GOAL
--------------------------------------------------------------------------------------------
maven-enforcer-plugin | validate | default | enforce
maven-dependency-plugin | process-sources | default | copy-dependencies
maven-resources-plugin | process-resources | default-resources | resources
maven-compiler-plugin | compile | default-compile | compile
maven-resources-plugin | process-test-resources | default-testResources | testResources
maven-compiler-plugin | test-compile | default-testCompile | testCompile
maven-surefire-plugin | test | default-test | test
maven-jar-plugin | package | default-jar | jar
maven-assembly-plugin | package | make-assembly | single
maven-install-plugin | install | default-install | install
maven-deploy-plugin | deploy | default-deploy | deploy
按阶段分组目标
> mvn fr.jcgay.maven.plugins:buildplan-maven-plugin:list-phase
validate -----------------------------------------------------------------
+ maven-enforcer-plugin | default | enforce
process-sources ----------------------------------------------------------
+ maven-dependency-plugin | default | copy-dependencies
process-resources --------------------------------------------------------
+ maven-resources-plugin | default-resources | resources
compile ------------------------------------------------------------------
+ maven-compiler-plugin | default-compile | compile
process-test-resources ---------------------------------------------------
+ maven-resources-plugin | default-testResources | testResources
test-compile -------------------------------------------------------------
+ maven-compiler-plugin | default-testCompile | testCompile
test ---------------------------------------------------------------------
+ maven-surefire-plugin | default-test | test
package ------------------------------------------------------------------
+ maven-jar-plugin | default-jar | jar
+ maven-assembly-plugin | make-assembly | single
install ------------------------------------------------------------------
+ maven-install-plugin | default-install | install
deploy -------------------------------------------------------------------
+ maven-deploy-plugin | default-deploy | deploy
按插件分组目标
> mvn fr.jcgay.maven.plugins:buildplan-maven-plugin:list-plugin
maven-enforcer-plugin ---------------------------------------------------
+ validate | default | enforce
maven-dependency-plugin -------------------------------------------------
+ process-sources | default | copy-dependencies
maven-resources-plugin --------------------------------------------------
+ process-resources | default-resources | resources
+ process-test-resources | default-testResources | testResources
maven-compiler-plugin ---------------------------------------------------
+ compile | default-compile | compile
+ test-compile | default-testCompile | testCompile
maven-surefire-plugin ---------------------------------------------------
+ test | default-test | test
maven-jar-plugin --------------------------------------------------------
+ package | default-jar | jar
maven-assembly-plugin ---------------------------------------------------
+ package | make-assembly | single
maven-install-plugin ----------------------------------------------------
+ install | default-install | install
maven-deploy-plugin -----------------------------------------------------
+ deploy | default-deploy | deploy
备注
默认情况下,目标搜索在用户调用mvn deploy
时将运行的任务。诸如clean
之类的阶段将不会被包括在内。要在搜索中包含多个阶段,请使用buildplan.tasks
属性:
> mvn fr.jcgay.maven.plugins:buildplan-maven-plugin:list -Dbuildplan.tasks=clean,deploy
发布于 2009-11-11 01:24:15
一个有用的工具是mvn help:effective-pom
,它将打印所有变量和所有父POM展开的POM。这有助于理解Maven看到的内容。由此,很容易找到所有额外的目标(通常不是很多)。
更大的问题是隐含的目标(即当插件自动将自己挂接到生命周期的某些阶段时)。在不实际运行Maven的情况下,没有简单的方法来查看这些内容。这在Maven3中应该会变得更好。在此之前,使用-X
运行Maven,它将打印出大量的调试输出以及当前阶段和执行的插件。
https://stackoverflow.com/questions/1709625
复制相似问题