7

我有一个很长的构建,其中包含大量步骤、插件和执行,这些步骤、插件和执行配置在大约 30 个 pom 中,属于一个复杂的模块化项目。由于构建花费了太多(2h),我想对其进行一些简化,为此我希望 maven 列出我在不执行它的情况下会经历的所有步骤。就像是:

$ mvn --dry-run clean
[INFO] Reactor Build Order:
[INFO] 
[INFO] Main project
[INFO] Module#1
[INFO] Module#2
[..]
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Main Project
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ main ---
[INFO] 
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Module#1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ module1 ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0:01.020s
[INFO] Finished at: Thu Apr 26 09:56:14 CEST 2012
[INFO] Final Memory: 198M/379M
[INFO] ------------------------------------------------------------------------

有没有办法在我不挖掘几兆的日志文件的情况下获得这样的信息?

4

1 回答 1

3

由于显然没有 OOTB 方法可以做到这一点,我最终编写了plan-maven-plugin。它允许您展开提供goals参数的计划:

mvn plan:plan -Dgoals=clean,javadoc:jar,sources:jar,package,gpg:sign,install

或将其作为正常构建的一部分执行:

mvn plan:plan clean javadoc:jar sources:jar package gpg:sign install

样本输出:

$ mvn plan:plan clean javadoc:javadoc package install site:site
[...]
[INFO] --- plan-maven-plugin:1.1:plan (default-cli) @ plan-maven-plugin ---
[INFO]
[INFO] Current lifecycle:
[INFO]     pre-clean
[INFO]     clean
[INFO]     post-clean
[INFO]     validate
[INFO]     initialize
[INFO]     generate-sources
[INFO]     process-sources
[INFO]     generate-resources
[INFO]     process-resources
[INFO]     compile
[INFO]     process-classes
[INFO]     generate-test-sources
[INFO]     process-test-sources
[INFO]     generate-test-resources
[INFO]     process-test-resources
[INFO]     test-compile
[INFO]     process-test-classes
[INFO]     test
[INFO]     prepare-package
[INFO]     package
[INFO]     pre-integration-test
[INFO]     integration-test
[INFO]     post-integration-test
[INFO]     verify
[INFO]     install
[INFO]     deploy
[INFO]
[INFO] Execution plan:
[INFO]     [-] tk.skuro:plan-maven-plugin:plan (default-cli)
[INFO]     [clean] org.apache.maven.plugins:maven-clean-plugin:clean (default-clean)
[INFO]     [-] org.apache.maven.plugins:maven-javadoc-plugin:javadoc (default-cli)
[INFO]     [validate] org.apache.maven.plugins:maven-enforcer-plugin:enforce (enforce-maven)
[INFO]     [generate-resources] org.apache.maven.plugins:maven-plugin-plugin:descriptor (default-descriptor)
[INFO]     [process-resources] org.apache.maven.plugins:maven-resources-plugin:resources (default-resources)
[INFO]     [compile] org.apache.maven.plugins:maven-compiler-plugin:compile (default-compile)
[INFO]     [process-test-resources] org.apache.maven.plugins:maven-resources-plugin:testResources (default-testResources)
[INFO]     [test-compile] org.apache.maven.plugins:maven-compiler-plugin:testCompile (default-testCompile)
[INFO]     [test] org.apache.maven.plugins:maven-surefire-plugin:test (default-test)
[INFO]     [package] org.apache.maven.plugins:maven-jar-plugin:jar (default-jar)
[INFO]     [package] org.apache.maven.plugins:maven-plugin-plugin:addPluginArtifactMetadata (default-addPluginArtifactMetadata)
[INFO]     [validate] org.apache.maven.plugins:maven-enforcer-plugin:enforce (enforce-maven)
[INFO]     [generate-resources] org.apache.maven.plugins:maven-plugin-plugin:descriptor (default-descriptor)
[INFO]     [process-resources] org.apache.maven.plugins:maven-resources-plugin:resources (default-resources)
[INFO]     [compile] org.apache.maven.plugins:maven-compiler-plugin:compile (default-compile)
[INFO]     [process-test-resources] org.apache.maven.plugins:maven-resources-plugin:testResources (default-testResources)
[INFO]     [test-compile] org.apache.maven.plugins:maven-compiler-plugin:testCompile (default-testCompile)
[INFO]     [test] org.apache.maven.plugins:maven-surefire-plugin:test (default-test)
[INFO]     [package] org.apache.maven.plugins:maven-jar-plugin:jar (default-jar)
[INFO]     [package] org.apache.maven.plugins:maven-plugin-plugin:addPluginArtifactMetadata (default-addPluginArtifactMetadata)
[INFO]     [install] org.apache.maven.plugins:maven-install-plugin:install (default-install)
[INFO]     [-] org.apache.maven.plugins:maven-site-plugin:site (default-cli)
[INFO]
于 2012-05-07T08:46:34.550 回答