#
MAVEN: Lifecycles
This tutorial explains what a Lifecycle is in Maven.
A lifecycle
in Maven defines the order of execution for some phases.
Each phase represents a specific step in the build process and has its own set of goals to be executed.
There are three built-in build lifecycles:
clean
: This lifecycle has 3 phases:- pre-clean: can be used for any tasks required prior to clean up
- clean: generally deletes the files from the "target" directory
- post-clean: can be used for tasks following the cleanup
The execution of a phase imply the execution on which depends: For instance, mvn clean
executes the "pre-clean" phase as well.
This is true for all Maven lifecycles.
default
: This lifecycle has the following phases (but not limited to):- validate: Validate if 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.
- verify: Run any checks on results of integration tests to ensure quality criteria are met
- install: Install the package into the local repository, for use as a dependency in other projects locally
- deploy: Done in the build environment, copies the final package to the remote repository for sharing with other developers and projects.
The complete list of Maven phases we have here.
site
: This lifecycle has the following phases:- pre-site: execute processes needed prior to the actual project site generation
- site: generate the project's site documentation
- post-site: execute processes needed to finalize the site generation, and to prepare for site deployment
- site-deploy: deploy the generated site documentation to the specified web server