在 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 ,也可以添加全新的生命周期。

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

最佳答案

这是一种误解。

通过“自定义生命周期”,所引用的书籍意味着目标与现有生命周期阶段的自定义绑定(bind)。 Lifecycle 一词用于三个 maven 生命周期的生命周期结构,仅由它们的 emtpy 阶段以及特定 maven 项目/模块的生命周期组成。

因此,您只能添加后一种类型的生命周期,作为 fork 的自定义生命周期或作为新包装类型的新绑定(bind)。但是,您不能创建具有全新生命周期阶段的新生命周期结构。

关于maven - 如何列出所有可用的 Maven 生命周期?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22287939/

10-13 09:21