Maven Concepts - Lifecycle
- 1 External
- 2 Internal
- 3 Overview
- 4 Lifecycle
- 5 Phases
- 5.1 Default Lifecycle Phases
- 5.1.1 validate
- 5.1.2 initialize
- 5.1.3 generate-sources
- 5.1.4 process-sources
- 5.1.5 generate-resources
- 5.1.6 process-resources
- 5.1.7 compile
- 5.1.8 process-classes
- 5.1.9 generate-test-sources
- 5.1.10 process-test-sources
- 5.1.11 generate-test-resources
- 5.1.12 process-test-resources
- 5.1.13 test-compile
- 5.1.14 process-test-classes
- 5.1.15 test
- 5.1.16 prepare-package
- 5.1.17 package
- 5.1.18 pre-integration-test
- 5.1.19 integration-test
- 5.1.20 post-integration-test
- 5.1.21 verify
- 5.1.22 install
- 5.1.23 deploy
- 5.2 Clean Lifecycle Phases
- 5.1 Default Lifecycle Phases
- 6 Plugin Goal
- Introduction to the Build Lifecycle https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
- Lifecycles Reference https://maven.apache.org/ref/3.3.9/maven-core/lifecycles.html#
A Maven lifecycle represents the clearly defined sequence of steps required for building and distributing a project artifact.
There are three built-in lifecycles: default, clean and site. The default lifecycle handles artifact building and deployment, and these are its phases. The clean lifecycle cleans the work area by executing the following phases. The site lifecycle handles the creation of the project's site documentation.
A lifecycle is defined by a sequence of build phases. The phases are executed sequentially.
A Maven phase represents a stage in a lifecycle.
Phases are usually invoked from command line. Invoking a phase means that all previous declared phases for the lifecycle are executed in order. For example:
executes validate, initialize, etc.
During the execution of a phase, the plugin goals bound to that phase are executed in order. A phase can have zero or more goals bound to it, and if the phase has zero goals, the phase will not execute during the lifecycle. If more than one goal is bound to a particular phase, the goals from the packaging are executed first, followed by those configured in POM. <executions> element provides more control over the order in which particular goals are executed. For more details on how to link a plugin goal to a specific phase, see:
Default Lifecycle Phases
The phase validates whether the project is correct and all necessary information is available.
The phase initializes the build state, sets properties, create directories, etc.
If generated sources are required by the compilation, they are created during this phase.
The phase processes the source code, this is where filtering is done.
The phase copies and processes the resources into the destination directory and makes them ready for packaging, by executing the "resources"resources" goal of the Maven Resources plugin.
For more details on how to specify the variables to be replaced, see: Maven Filtering and Property Substitution.
The phase compiles the source code.
Executes operations such as byte code manipulation, etc.
The phase tests the compiled source code by using a suitable test framework. The tests should not require the code to be packaged or deployed.
The phase packaged the compiled code in a distributable format. Also see <packaging>.
If using the assembly plugin, this is usually the phase where the plugin's "single" goal is associated with.
The phase Installs the packaged artifact into the local repository.
The phase copies the packaged artifact to a remote repository.
Clean Lifecycle Phases
A goal may be bound to zero or more build phases. If a goal is bound to more than one phase, it will be called in all the phases it is bound to.