2012-04-26 190 views
7

我有一個很長的版本,其中包含大量的步驟,插件和執行配置在大約30 poms屬於一個複雜的模塊化項目。由於構建需要太多時間(2h),所以我想簡化它,爲此,我希望maven列出所有將要執行的步驟而不執行它。像這樣的: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] ------------------------------------------------------------------------ 

有沒有什麼方法可以讓我沒有這樣的信息挖掘一些日誌文件的megs?

+1

我沒有遇到可以做到這一點的插件。但快速搜索顯示Maven API中有一個名爲[MavenExecutionPlan]的類(http://maven.apache.org/ref/3.0.4/maven-core/apidocs/org/apache/maven/lifecycle/MavenExecutionPlan.html )。也許你可以以某種方式使用它。 – 2012-04-26 19:22:21

回答

1

由於顯然沒有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] 
+0

感謝您的偉大的插件。幫助很多:) – 2013-06-18 14:31:05