maven life cycle
maven has three built-in build life cycles: default, clean, site
- clean phase: handles the cleanup of the project
- default stage: process the deploy of the project
- site stage: handles the creation of the website site
The life cycle of a build consists of a series of phases (phases)
Each life cycle (default\clean\site) consists of a series of phases, each phase representing a step in the life cycle
Next, we will talk about the three built-in life cycles and their phase relationships:
The clean life cycle consists of the following phases:
- pre-clean : some preprocessing work to do before the project is actually cleaned
- clean: remove all files generated by the last build process
- post-clean : Finish the final project clean work
The default life cycle consists of the following phases:
- validate : Validate that this item is correct and that all required resources are available
- initialize : Initialize the compiled state, for example: set some properties, or create some directories
- generate-sources : generate all the source code needed during the compilation phase
- process-sources : process the source code, e.g. filter any values
- generate-resources : Generate all the resource files that need to be included in this project package
- process-resources : Copy and process resource files to the target directory in preparation for the packaging phase
- compile : compile the source code of the project
- process-classes : Post-processing the files generated during the compilation phase, for example: do the enhancement of java bytecode
- generate-test-sources : Generate the test source code required for the compilation phase
- process-test-sources : process test source code, e.g. replace values (filter any values)
- generate-test-resources : Generate the resource files required by the test test
- process-test-resources : Copy and process resource files to the test target directory
- test-compile : compile the test code of the project to the specified test target directory
- process-test-classes : Post-process the files generated in the test compilation phase, for example: do the enhancement of java bytecode
- test : Use a suitable unit testing framework to run all test cases that should not require the code to be packaged or deployed to execute
- prepare- package : Handles any necessary preparations that need to be done before formal packaging. The usual result of this step is unzipping, handling package versions, etc.
- package : package the compiled code into a deliverable format, such as jar, war, etc.
- pre-integration-test : Do some preprocessing operations that need to be done before integration testing, this usually includes setting up the required environment.
- integration-test : Process and deploy the package into an environment where integration tests can run
- post-integration-test : handles some post-integration testing, usually including some environment cleanup
- verify : Do some verification operations on the package to check that the package is a legitimate standard-compliant package.
- install : Install the package to the local repository and provide it for use in other projects, for example: local dependencies of the package
- deploy : The final result is to deploy to an integrated environment or a formal environment, copy the final version to a remote repository and share it with other projects or developers
The site life cycle consists of the following phases:
- pre-site : perform some preprocessing operations before actual site generation
- site : Generates site documentation for the project
- post-site :执行一些后置操并完成最终生成站点操作,并为最后站点发布做好准备
- site-deploy :部署这个生成好的站点文档到指定的web服务器
goal 和liftcycle phase关系
内置的生命周期绑定:
一些阶段有一些目标(goal)默认和他们是绑定在一起的。并且,对于默认的生命周期,这个绑定依赖pom 文件里面的packaging 的值。
常见的目标绑定编译阶段(goal-to-build-phase bindings)
clean生命周期和目标的绑定关系:
- phase goal
- clean clean:clean
default生命周期和目标绑定关系:
当packaging值是jar / rar / war
- phase goal
- process-resources resources:resources
- compile compiler:compile
- process-test-resources resources:testResources
- test-compile compiler:testCompile
- test surefire:test
- package jar:jar or rar:rar or war:war
- install install:install
- deploy deploy:deploy
当packaging值是maven-plugin
- phase goal
- generate-resources plugin:descriptor
- process-resources resources:resources
- compile compiler:compile
- process-test-resources resources:testResources
- test-compile compiler:testCompile
- test surefire:test
- package jar:jar and plugin:addPluginArtifactMetadata
- install install:install
- deploy deploy:deploy
当packaging值是pom
- phase goal
- package site:attach-descriptor
- install install:install
- deploy deploy:deploy
site生命周期和目标绑定关系:
- phase goal
- package site:attach-descriptor
- install install:install
- deploy deploy:deploy
参考资料:
lifecycle官方定义:http://maven.apache.org/ref/3.5.0/maven-core/lifecycles.html
build:http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference
http://www.iteye.com/news/32493