maven-release-plugin-example
Cleaning a Release
-
Delete the release descriptor (release.properties)
-
Delete any backup POM files
mvn release:clean
Preparing the Release
-
Perform some checks – there should be no uncommitted changes and the project should depend on no SNAPSHOT dependencies
-
Change the version of the project in the pom file to a full release number (remove SNAPSHOT suffix) – in our example – 0.1
-
Run the project test suites
-
Commit and push the changes
-
Create the tag out of this non-SNAPSHOT versioned code
-
Increase the version of the project in the pom – in our example – 0.2-SNAPSHOT
-
Commit and push the changes
Dry Run
Allows you to run all operations in release:prepare
goal except for actual commits into SCM.
mvn release:prepare -DdryRun=true
Performing the Release
-
Checkout release tag from SCM
-
Build and deploy released code
-
Relies on the output of the Prepare step – the
release.properties
.
mvn release:prepare
Hosted Maven2 repository in Nexus
Create maven2 hosted repository in Nexus, for us it's api-release
Upload artifact in Nexus from command line:
curl -v --user admin:admin123 --upload-file <filename> http://localhost:8081/repository/<repository-name>/<filename>
settings.xml
(%USER_HOME%/.m2/settings.xml):
Configure the credentials for the nexus-releases server in the global <servers>
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
Cleaning, Preparing and Performing the release
mvn release:clean release:prepare release:perform -DreleaseVersion=0.1 -DdevelopmentVersion=0.2-SNAPSHOT
Reference: http://www.baeldung.com/maven-release-nexus