Maven Build Cycle
Introduction#
Following is a complete list of Maven’s default build lifecycle phases. Each of these phases is invoked by adding it to the mvn command, e.g. mvn install.
Maven Build Lifecycle Phases
validateValidates whether the project is correct and all the required information are available for the build.
initializeInitializes the build environment, e.g. sets properties or creates directories.
generate-sourcesGenerates source code to be processed in the ‘compile’ phase.
process-sourcesProcesses the source code in case some filter need to be applied.
generate-resourcesGenerates resources to be included in the artifact.
process-resourcesProcesses and copies resources into the output directory (${basedir}/target/classes).
compileCompiles the project’s source code in the source directory (${basedir}/src/main/[java|groovy|...]) into the output directory (${basedir}/target/classes).
process-classesProcesses .class files generated in the compile phase, e.g. to perform bytecode enhancements.
generate-test-sourcesGenerates test source code to be processed in the test-compile phase.
process-test-sourcesProcesses test source code in case some filter need to be applied.
generate-test-resourcesGenerates resources for testing.
process-test-resourcesProcesses and copies test resources in the resources directory (${basedir}/src/main/resources) into the test output directory (${basedir}/target/test-classes).
test-compileCompiles source code in the test source directory (’${basedir}/src/test/[java|groovy|…]’) into the test output directory(${basedir}/target/test-classes).
process-test-classesProcesses test .class files generated in the test-compile phase, e.g. to perform bytecode enhancements (Maven 2.0.5 and above).
testRuns tests using some suitable test framework. Note: These test cases are not considered for packaging and deploying.
prepare-packagePerforms final changes and validations before the package is finally created.
packagePackages the successfully compiled and tested code into some distributable format like JAR, WAR, EAR into the target directory (${basedir}/target).
pre-integration-testPerforms actions before integration tests are run if they require to apply some changes in the environment for the application.
integration-testProcesses and possibly deploys the application to an environment where integration tests can be run.
post-integration-testPerforms actions after the integration tests, like cleaning up the environment which has been created in the pre-integration-test phase.
verifyChecks whether a package is valid and meets required quality criteria.
installInstalls the artifact into the local repository. Any other local project can use this artifact as one of its dependencies after that (if your IDE doesn’t support workspace dependency resolution anyway).
deployCopies the package to a remote repository to make it available for other developers.