Release Plugin

The release plugin allows you to perform software releases it follows a series of steps to perform a release of your current project. The release plugin saves a lot of repetitive, manual work, releasing a project is made in two steps: prepare and perform.

Release Process Overview

The release plugin basically releases versions of you project, for example the process would be as follows

Trying to perform the above manually (a lot of repeative tasks) would be very error prone, tis is where the release plugin comes into play. The two steps are below

Prepare Release Perform Release
  • Check no uncommitted changes
  • Check no snapshots
  • Update release version
  • Run tests
  • Tag in SCM
  • Next snapshot version
  • Commit
  • Checkout of SCM with SCM tag
  • Run release goals (default deploy site deploy)
  • Remove release files
  • Checkout SCM master

If there are any problems a release rollback (release:rollback)might be needed

release:clean will perform the following

SCM Plugin Setup

The Source Control Management plugin can be used to work with the companies SCM solution (example Github or GitLab), it fully suports a number of of SCM versions (for example Git, CVS, Subversion, etc).

To configure the SCM we need to perform the following, you will also need to setup the SCM in the settings.xml file

First we add a propery called project.scm.id that points to the settimgs.xml git setup (see below), then we add the scm element (right-hand screenshot), all three pieces allows you to connect to github for source control management.

The settings.xml github setup


Release Plugin Setup

To setup the release plugin in the POM file we need to add an additional plugin as per below


Release Prepare, Perform and Rollback

Now that Maven is setup we can start to run the commands to prepare and perform a release

prepare
mvn clean release:prepare

Note: Maven will ask you for the release (select default) and the snapshot (select default), 
two files will be created a backup of the POM and a release.properties file.
prepare (dryrun)
mvn release:prepare -DdryRun=true

Note: dryRun will will put not change anything but ive us the output, good for checking before you run for real.
perform
mvn release:perform

Note: This will also deploy (Packagecloud or Nexus for example)

After the perform the POM version will be updated


If you need to rollback a release (cannot do if you have run release:clean)

rollback
mvn release:rollback

Note: this will remove the backup POM, remove the release.properties file and rollback the <version>, 
however it won't update github this has to be done manually.