Monday, July 2, 2007

Release Plugin "Dry Run"

The problem:

Running the "release:prepare" command in Maven does a number of caustic things. It will check in and tag your code in the SCM you use. It will also change the projects pom, rolling the version number up. If you have any "SNAPSHOT" dependencies it will fail.

The solution:


Maybe you want to do a "dry run" before executing a command that could muck up your SCM and pom? By "dry run" I mean the release plug in goes through the motions, but nothing is changed in the SCM, and your pom doesn't get messed up. Here is what you do:
mvn release:prepare -DdryRun
The "-DdryRun" tells the plug in to not fully perform the preparation. You will find this generates some temporary files in the project folder. These include:
  • pom.xml.next : what the projects pom looks like after the release
  • pom.xml.releaseBackup : what the pom looked like before
  • pom.xml.tag : the pom for the tagged version of project
  • release.properties : the information about the release of the project
It is not likely you want to keep these files around for too long. You can remove these file by running this command:
mvn release:clean
I recommend you use this whenever you are getting ready to release. It will save you a lot of time, because just one botched release attempt could take minutes to clean up. The dry run will take seconds to run.