Maven build lifecycles, phases and goals
August 21, 2009 03:05:23 Last update: August 22, 2009 22:10:06
There are three built-in build lifecycles:
Each of these build lifecycles is defined by a different list of build phases, wherein a build phase represents a stage in the lifecycle.
The default lifecycle has the following most common build phases (among others):
A build phase can also have zero or more goals bound to it. If a build phase has no goals bound to it, that build phase will not execute. But if it has one or more goals bound to it, it will execute all those goals (multiple goals bound to a phase are executed in the same order as they are declared in the POM).
Goals are bound to build phases by the type of
Default Lifecycle Bindings - Packaging
Default Lifecycle Bindings - Packaging
Reference:
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference
- default: handles your project deployment
- clean: handles project cleaning
- site: handles the creation of your project's site documentation
Each of these build lifecycles is defined by a different list of build phases, wherein a build phase represents a stage in the lifecycle.
The default lifecycle has the following most common build phases (among others):
| Phase | Description |
|---|---|
| validate | validate the project is correct and all necessary information is available |
| compile | compile the source code of the project |
| test | test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed |
| package | take the compiled code and package it in its distributable format, such as a JAR. |
| integration-test | process and deploy the package if necessary into an environment where integration tests can be run |
| verify | run any checks to verify the package is valid and meets quality criteria |
| install | install the package into the local repository, for use as a dependency in other projects locally |
| deploy | done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects |
A build phase can also have zero or more goals bound to it. If a build phase has no goals bound to it, that build phase will not execute. But if it has one or more goals bound to it, it will execute all those goals (multiple goals bound to a phase are executed in the same order as they are declared in the POM).
Goals are bound to build phases by the type of
packaging, or with plugins. For example, if packaging is jar, then the package phase will execute the jar:jar goal. If the packaging is pom, the goal executed will be site:attach-descriptor.
Default Lifecycle Bindings - Packaging
ejb / ejb3 / jar / par / rar / war
| Phase | Goal |
|---|---|
process-resources | resources:resources |
compile | compiler:compile |
process-test-resources | resources:testResources |
test-compile | compiler:testCompile |
test | surefire:test |
package | ejb:ejb or ejb3:ejb3 or jar:jar or par:par or rar:rar or war:war |
install | install:install |
deploy | deploy:deploy |
Default Lifecycle Bindings - Packaging
ear
| Phase | Goal |
|---|---|
generate-resources | ear:generateApplicationXml |
process-resources | resources:resources |
package | ear:ear |
install | install:install |
deploy | deploy:deploy |
Reference:
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference