Maven build lifecycles, phases and goals 

Joined:
08/13/2009
Posts:
172

August 21, 2009 03:05:23    Last update: August 22, 2009 22:10:06
There are three built-in build lifecycles:
  1. default: handles your project deployment
  2. clean: handles project cleaning
  3. 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):
PhaseDescription
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
deploydone 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
PhaseGoal
process-resourcesresources:resources
compilecompiler:compile
process-test-resourcesresources:testResources
test-compilecompiler:testCompile
testsurefire:test
packageejb:ejb or ejb3:ejb3 or jar:jar or par:par or rar:rar or war:war
installinstall:install
deploydeploy:deploy


Default Lifecycle Bindings - Packaging ear
PhaseGoal
generate-resourcesear:generateApplicationXml
process-resourcesresources:resources
packageear:ear
installinstall:install
deploydeploy:deploy


Reference:
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference
Share |
| Comment  | Tags