首页 > 代码库 > maven生命周期

maven生命周期

maven都有哪些生命周期

在maven中定义了三种生命周期,分别为default lifecycle,clean lifecycle和site lifecycle.而第一种默认的生命周期是不需要与插件关联的,相对默认生命周期,则clean lifecycle和site lifecycle需要插件的支持。

default lifecycle

以下则是默认生命周期里按照构建的顺序列出了生命周期的各个环节,对于各个环节所表示的意思则可以从字面意思上很容易的理解:

  1. validate

  2. generate-sources

  3. process-sources

  4. generate-resources

  5. process-resources

  6. compile

  7. process-classes

  8. generate-test-sources

  9. process-test-sources

  10. generate-test-resources

  11. process-test-resources

  12. test-compile

  13. test

  14. prepare-package (maven 2.1+)

  15. package

  16. pre-integration-test

  17. integration-test

  18. post-integration-test

  19. verify

  20. install

  21. deploy


clean lifecycle

此种生命周期中包含pre-clean,clean,post-clean三个环节。例如:

<phases>
  <phase>pre-clean</phase>
  <phase>clean</phase>
  <phase>post-clean</phase>
</phases>
<default-phases>
  <clean>
    org.apache.maven.plugins:maven-clean-plugin:2.5:clean
  </clean>
</default-phases>


site lifecycle

此种生命周期中包含pre-site,site,post-site,site-deploy四个环节,例如:

<phases>
  <phase>pre-site</phase>
  <phase>site</phase>
  <phase>post-site</phase>
  <phase>site-deploy</phase>
</phases>
<default-phases>
  <site>
    org.apache.maven.plugins:maven-site-plugin:3.3:site
  </site>
  <site-deploy>
    org.apache.maven.plugins:maven-site-plugin:3.3:deploy
  </site-deploy>
</default-phases>



maven生命周期