Used to perform a release of a project with Maven.
Key goals in mvn release Plugin
- release:clean Clean up after a release preparation.
- release:prepare Prepare for a release in SCM(Source Code Management i.e. nexus).
- release:rollback Rollback a previous release.
- release:perform Perform a release from SCM.
Prerequisite
Since this plugin releases artifacts(could be JAR’s, ZIP’s WAR’s or TAR’s) into the repository we need to make sure
credentials are properly configured in settings.xml in the conf folder, Maven installation directory. Failing to do so would
end up in authorization error while running the goals in the plugin
Syntax
>>mvn release:clean release:prepare >>mvn release:perform
How it Works
- Once you run release:clean it would clean the old class files just like maven clean
- When you run release:prepare it would read the pom.xml in the project. If you don’t have snapshot version defined you would end up with snapshot not found error since the
plugin assumes snapshot is the one which needs to be released. - Now on running release:prepare will ask for the name of the version and will change the line snapshot in pom.xml. It also does a git push of pom.xml in the remote repo
- When you run release:perform it will push the jar in the nexus repo so it would be available for other teams.
- When you are working on App-Model-0.0.1-SNAPHSOT using mvn:prepare and mvn:perform would put App-Model-0.0.1 in repo at the same time modifying pom.xml in local and git to 0.0.2-SNAPSHOT. So the dependent project needs to be updated likewise
Other know issues:
Sometime the release:perform fails because it complains tag already exists in repo. In such a case, you need to delete the tags and perform release again.
During the release, the list of files that needs to go along release would be tagged to particular version. In some cases, there would be files with the same tag name. In such case, maven-plugin complains the tag already exists.
To get the recent Tag
//Recent Tags git describe --tags //Latest Tags - With --abbrev=0 it should return closest annotated tag git describe --abbrev=0
To delete the tag
git fetch is needed to get the remote tags to be displayed in local, kind of refresh
//To delete tag locally git tag -d TAG_NAME git fetch //To delete tag remote git push --delete origin TAG_NAME
To get the Latest tags for different commits done across various branches
git describe --tags $(git rev-list --tags --max-count=1)