如何列出所有可用的maven生命周期?

时间:2014-03-09 20:45:31

标签: maven

在maven中,可以使用help:describe列出某个生命周期的所有阶段:

$ mvn help:describe -Dcmd=package
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-help-plugin:2.2:describe (default-cli) @ standalone-pom ---
[INFO] 'package' is a phase corresponding to this plugin:

It is a part of the lifecycle for the POM packaging 'pom'. 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: Not defined
* compile: Not defined
* process-classes: Not defined
* generate-test-sources: Not defined
* process-test-sources: Not defined
* generate-test-resources: Not defined
* process-test-resources: Not defined
* test-compile: Not defined
* process-test-classes: Not defined
* test: Not defined
* prepare-package: Not defined
* package: Not defined
* 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

这需要指定该生命周期的某些(任意?)阶段。

我知道clean, default, and site lifecycle

如果我正确理解this section,也可以添加全新的生命周期。

是否有命令列出所有可用的生命周期以及它们由哪些阶段组成?

1 个答案:

答案 0 :(得分:0)

这是一种误解。

通过“自定义生命周期”,引用的书意味着目标与现有生命周期阶段的定制绑定。术语生命周期用于三个maven生命周期的生命周期结构,仅包括其emtpy阶段以及特定maven项目/模块的生命周期。

因此,您只能添加后一种类型的生命周期,作为分叉的自定义生命周期或新包装类型的新绑定。但是,您不能使用完全新的生命周期阶段创建新的生命周期结构。