mvn clean install vs. deploy vs. release
I am just learning maven, and we have recently needed to go more and more. I would like to know the difference between
mvn clean install
mvn release
mvn deploy
Please be as descriptive as possible.
The clean
, install
and deploy
phases are valid lifecycle phases and invoking them will trigger all the phases preceding them, and the goals bound to these phases.
mvn clean install
This command invokes the clean
phase and then the install
phase sequentially:
-
clean
: removes files generated at build-time in a project's directory (target
by default) -
install
: installs the package into the local repository, for use as a dependency in other projects locally.
mvn deploy
This command invokes the deploy
phase:
-
deploy
: copies the final package to the remote repository for sharing with other developers and projects.
mvn release
This is not a valid phase nor a goal so this won't do anything. But if refers to the Maven Release Plugin that is used to automate release management. Releasing a project is done in two steps: prepare
and perform
. As documented:
Preparing a release goes through the following release phases:
- Check that there are no uncommitted changes in the sources
- Check that there are no SNAPSHOT dependencies
- Change the version in the POMs from x-SNAPSHOT to a new version (you will be prompted for the versions to use)
- Transform the SCM information in the POM to include the final destination of the tag
- Run the project tests against the modified POMs to confirm everything is in working order
- Commit the modified POMs
- Tag the code in the SCM with a version name (this will be prompted for)
- Bump the version in the POMs to a new value y-SNAPSHOT (these values will also be prompted for)
- Commit the modified POMs
And then:
Performing a release runs the following release phases:
- Checkout from an SCM URL with optional tag
- Run the predefined Maven goals to release the project (by default, deploy site-deploy)
See also
- Introduction to the Build Lifecycle
- The Maven Release Plugin
-
mvn install
will put your packaged maven project into the local repository, for local application using your project as a dependency. -
mvn release
will basically put your current code in a tag on your SCM, change your version in your projects. -
mvn deploy
will put your packaged maven project into a remote repository for sharing with other developers.
Resources :
- Maven install plugin
- Maven release plugin
- Maven deploy plugin