Version management with gradle can sound like a daunting task. There are a plethora of “plugins” out there that attempt to solve this problem but most of them are either disappointing, do not work or have been abandoned.
To solve this problem I’ve created the
versionest gradle plugin to help aid you in your quest with semantic versioning automation!
Getting setup to use the versionest plugin is as simple as adding a few lines to your
build.gradle file and creating an initial
Add the following (or append) to the top of your build.gradle file in your project root. This will configure the repository to look for the
versionest plugin and then apply it (activate it).
Notice this last line, this is where the magic happens.. each time your build runs the
version variable is set by the
versionest.version.toString() method which simply reads from the
This file holds the semantic version for your project. This format uses MAJOR.MINOR.PATCH:
Now that our build is setup to use the plugin we can go ahead and call our gradle tasks to effectively manage the versions.
The following tasks are currently available:
bumpMajorVersion bumpMinorVersion bumpPatchVersion createVersionFile getCurrentVersion
By calling a
bump* task you will increment the value in
version.properties auto-magically. You could then daisy chain tasks to do things like always bump on build, upload, etc.
versionest is an open-source project. Source code is hosted at https://github.com/mateothegreat/gradle-plugin-versionest and jars are available via my nexus repository server at https://nexus.matthewdavis.io/#browse/browse:gradle.plugins.