在Maven2中有了明确的生命周期概念,而且都提供与之对应的命令,使得项目构建更加清晰明了。主要的生命周期阶段:
There are two other Maven lifecycles of note beyond the default list above. They are
- validate,验证工程是否正确,所有需要的资源是否可用。
- compile,编译项目的源代码。
- test-compile,编译项目测试代码。
- test,使用已编译的测试代码,测试已编译的源代码。
- package,已发布的格式,如jar,将已编译的源代码打包。
- integration-test,在集成测试可以运行的环境中处理和发布包。
- verify,运行任何检查,验证包是否有效且达到质量标准。
- install,把包安装在本地的repository中,可以被其他工程作为依赖来使用
- deploy,在整合或者发布环境下执行,将最终版本的包拷贝到远程的repository,使得其他的开发者或者工程可以共享。
- generate-sources,产生应用需要的任何额外的源代码,如xdoclet。
There are two other Maven lifecycles of note beyond the default list above. They are
- clean: cleans up artifacts created by prior builds
- site: generates site documentation for this project
Maven生命周期中的各个阶段自下向上依赖,也就是执行一个阶段的指令实际上是对一段生命周期的执行。