Montag, 15. Dezember 2014

My Lightweight Release Process

"If it's not on Maven Central, it doesn't exist!"

I always feel sad when I see a nice little library and the usage instructions say something like "download the jar and put it on your project's classpath". It's 2014 and your project deserves to be in a public repository!

But getting it there can be tedious without the right tools. Not only should you build a jar, you also want sources and javadoc, all of them digitally signed. On top of that you need to provide lots of metadata in the form of a pom.xml, espescially if you want to be listed on Maven Central.

This is why I created a Gradle plugin that automates as much of the metadata collection and publishing as possible. The goal is to just push a tag to Github and have the released artifacts available on public repositories a few minutes later without any manual steps.

An example configuration looks like this:

A Maven Central compliant POM can be completely derived from that little script. SCM information, project URL and issue management URL are all calculated from the github username and project name. The license is taken from the LICENSE file in the project root directory. The devolopers section is copied from the defined contacts.

The plugin allows you to call a release task and supply the version number on the command line. This is very useful for patterns like "release on tag" or "release on every commit". But you could also easily extend it to display a modal dialog and ask for the required information if you want to do manual releases.

I do my releases on every tag that is pushed to the Github repository. On travis-ci this only requires a short script and setting the passwords as environment variables. The steps are described at the end of the readme.

With this plugin, the only manual steps left are one-time tasks like getting a Sonatype account and creating signing keys. After that, you can build and release new projects within minutes.