1. Three sets of life cycles
Maven has three sets of independent life cycles, which are clean, default and site.
Each life cycle contains some stages, these stages are sequential, and the later stages depend on the previous ones. The most direct interaction between users and Maven is to call these life cycle stages.
Take the clean life cycle as an example, it contains the phases pre-clean, clean and post clean. When the user calls pre-clean, only pre-clean is executed. When the user calls clean, the pre-clean and clean phases are executed sequentially; when the user calls post-clean, pre-clean, clean, post -clean will be executed sequentially.
Compared with the before and after dependencies of the life cycle stages, the three life cycles are independent of each other. Users can only call a certain stage of the clean life cycle, or only call a certain stage of the default life cycle, without affecting other life cycles. cycles have no effect.
2. clean life cycle
The purpose of the clean lifecycle is to clean the project and it consists of three phases:
1) pre-clean performs some work that needs to be done before cleaning.
2) clean cleans up the files generated by the last build.
3) post-clean performs some work that needs to be done after cleaning.
3. default life cycle
The default life cycle defines all the steps that need to be performed when a real component is used. It is the core part of the life cycle. It contains the following stages:
1) validate verifies that the project is correct and that all required related resources are available
2) initialize initialize the build
3) generate-sources
4) process-sources process source code
5) generate-resources
6) process-resources Process the project main resource file. After performing variable substitution and other work on the contents of the src/main/resources directory, copy it to the main classpath directory of the project output.
7) compile compiles the main source code of the project
8) process-classes
9) generate-test-sources
10) process-test-sources process project test resource files
11)generate-test-resources
12) process-test-resources process test resource files
13) test-compile compiles the test code of the project
14)process-test-classes
15) test uses the unit testing framework to run tests, the test code will not be packaged or deployed
16) prepare-package is ready for packaging
17) package accepts compiled code and packages it into a releasable format
18) pre-integration-test
19) integration-test
20) post integration-test
21) verify
22) install installs the package to the Maven local repository for use by other local Maven projects
23) deploy copies the final package to the remote repository for use by other developers and Maven projects
4. site life cycle
site生命周期的目的是建立和发布项目站点,Maven能够基于POM所包含的信息,自动生成一个友好的站点,方便团队交流和发布项目信息。该生命周期包含如下阶段:
1)pre-site 执行一些在生成项目站点之前需要完成的工作
2)site 生成项目站点文档
3)post-site 执行一些在生成项目站点之后需要完成的工作
4)site-deploy 将生成的项目站点发布到服务器上