Maven Build Life Cycles, Phases and Goals

Maven build life cycle is divided into build phases, and the build phases are divided into build goals.

Maven Build Phase:

A phase represents a stage in life cycle. The build phases are subdivided into goals.

Maven Build Goal:

Build goals are the finest steps in the Maven build process which represents a specific task. A goal can be bound to none, one or more build phases. If a goal is not bound to any build phase, we can only execute it by passing the goals name to the mvn command.

Maven Build Lifecycle Phases:

PhaseDescription
prepare-resourcesThis phase is used to can be customize the resource copying.
validate Validate the project is correct and all necessary information is available.
compileIt compiles the source code of the project.
TestTests the compiled source code using a suitable testing framework.
packageThis phase take the compiled code and creates the JAR/WAR package as mentioned in the packaging in POM.xml.
installThis phase installs the package in local maven repository.
DeployThis phase copies the final package to the remote repository.

Build Life Cycles:

Maven has following 3 built-in build life cycles:
1. default
2. clean
3. site

Please Share