Maven Release Plugin
- This plugin is used to release a project with Maven, saving a lot of repetitive, manual work. Releasing a project is made in two steps: prepare and perform.
Requriements:
1) Current version specified in your projects pom.xml should be a SNAPSHOT version
eg. 1.1-SNAPSHOT
2) your projects pom.xml should contain the scm connection settings specified inside scm tag (maven-scm-plugin)
eg.
<scm>
<connection>scm:svn:https://your.projects.svn.path</connection>
<developerConnection>scm:svn:https://your.projects.svn.path</developerConnection>
</scm>
<connection>scm:svn:https://your.projects.svn.path</connection>
<developerConnection>scm:svn:https://your.projects.svn.path</developerConnection>
</scm>
"https://your.projects.svn.path" this is the path where maven checkins the next developemnt version
3) your pom.xml must contain repositories configuration under distributionManagement tag.
eg.
<distributionManagement>
<repository>
<id>releases</id>
<name>Releases</name>
<url>http://your.server.path/nexus/content/repositories/releases/</url>
<layout>default</layout>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Snapshots</name>
<url>http://your.server.path/nexus/content/repositories/snapshots/</url>
<layout>default</layout>
</snapshotRepository>
</distributionManagement>
<repository>
<id>releases</id>
<name>Releases</name>
<url>http://your.server.path/nexus/content/repositories/releases/</url>
<layout>default</layout>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Snapshots</name>
<url>http://your.server.path/nexus/content/repositories/snapshots/</url>
<layout>default</layout>
</snapshotRepository>
</distributionManagement>
4) your maven's settings.xml must contain the required server configuration
eg.
<servers>
<server>
<id>releases</id>
<username>yourusername</username>
<password>yourpassword</password>
</server>
<server>
<id>snapshots</id>
<username>yourusername</username>
<password>yourpassword</password>
</server>
</servers>
<server>
<id>releases</id>
<username>yourusername</username>
<password>yourpassword</password>
</server>
<server>
<id>snapshots</id>
<username>yourusername</username>
<password>yourpassword</password>
</server>
</servers>
Steps to follow :
- mvn release:prepare -DdryRun=true -DautoVersionSubmodules=true -P "production" -DtagBase=https://your.svn.tagbase.path
"https://your.svn.tagbase.path" this is the path where branch/tag is created for the current release, which is than checkout in target folder and the same is uploaded on nexus during perform step. - mvn release:perform -DdryRun=true -P "production"
- mvn release:clean
- mvn release:prepare -DautoVersionSubmodules=true -P "production" -DtagBase=https://your.svn.tagbase.path
- mvn release:perform -P "production"
- Dependent project POM files should refer new SNAPSHOT version.
- If problem occurred while performing common release than execute the below commands for rollback.
a) mvn release:rollback
To rollback a release, the following requirement must be met:
- You haven't run release:clean on the project. This means that the backup files and the release descriptor from the previous release command still exists.
- All project POMs are reverted back to their pre-release state locally, and also in the SCM if the previous release command was able to successfully make changes in the SCM to the POMs. This is done by using the backup files created during release:prepare.
b) mvn release:clean
Cleaning a release goes through the following release phases:
- Delete the release descriptor (release.properties)
- Delete any backup POM files
No comments:
Post a Comment