首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Maven命令来列出生命周期阶段和约束目标?

Maven命令来列出生命周期阶段和约束目标?
EN

Stack Overflow用户
提问于 2009-11-11 01:16:52
回答 4查看 38K关注 0票数 120

我只是在学习Maven,所以这可能是显而易见的,但我找不到一种简单的方法来列出给定项目的每个maven生命周期阶段的相关目标。

我看到Maven默认生命周期阶段和相应的缺省目标都记录在here中。到目前为止,我的理解是,每个pom.xml可以将额外的目标绑定到每个生命周期阶段。

那么,是否有一个mvn命令来确定将为给定项目的每个生命周期阶段运行的目标?如果不是,我想我只需要查看每个新的maven项目的pom.xml就可以解决这个问题了。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2010-01-15 01:31:09

mvn help:describe -Dcmd=compile (或任何其他有效阶段)

票数 135
EN

Stack Overflow用户

发布于 2016-02-25 02:41:49

buildplan-maven-plugin是一个很好的工具,用于显示目标是如何绑定到阶段的。

下面是您可以运行的命令示例。如果插件尚未安装,这些命令将自动下载并安装该插件。

按目标执行的顺序列出目标

代码语言:javascript
复制
> 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

按阶段分组目标

代码语言:javascript
复制
> 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

按插件分组目标

代码语言:javascript
复制
> 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属性:

代码语言:javascript
复制
> mvn fr.jcgay.maven.plugins:buildplan-maven-plugin:list -Dbuildplan.tasks=clean,deploy
票数 158
EN

Stack Overflow用户

发布于 2009-11-11 01:24:15

一个有用的工具是mvn help:effective-pom,它将打印所有变量和所有父POM展开的POM。这有助于理解Maven看到的内容。由此,很容易找到所有额外的目标(通常不是很多)。

更大的问题是隐含的目标(即当插件自动将自己挂接到生命周期的某些阶段时)。在不实际运行Maven的情况下,没有简单的方法来查看这些内容。这在Maven3中应该会变得更好。在此之前,使用-X运行Maven,它将打印出大量的调试输出以及当前阶段和执行的插件。

票数 19
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1709625

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档