A Build Lifecycle is a sequence of
tasks we used to build software. For example, compile, test, test more,
package and publish or deploy are all tasks we need to do to build software.
A Maven build lifecycle is the sequence of phases we need to go through in order to finish building the
software.
The following table lists some of
the build lifecycle.
Maven has the following three standard
lifecycles:
Ø clean
Ø default
(or build)
Ø site
These build phases are executed
sequentially to complete the default lifecycle.
Given the build phases above, when
the default lifecycle is used, Maven will
1. validate
the project
2. compile
the sources
3. run
those against the tests
4. package
the binaries (e.g. jar)
5. run
integration tests against that package
6. verify
the package
7. install
the verifed package to the local repository
8. deploy
the installed package in a specified environment
To do all those, you only need to
call the last build phase to be executed, in this case, deploy:
mvn deploy
Calling a build phase will execute
not only that build phase, but also every build phase prior to the called build
phase.
mvn integration-test
will do every build phase before
it (validate, compile, package, etc.), before executing integration-test.
The same command can be used in a
multi-module with one or more subprojects. For example:
mvn clean install
This command will traverse into
all of the subprojects and run clean, then install including all of the prior
steps.
Clean Lifecycle Reference
Default Lifecycle Reference
Site Lifecycle Reference