JPragma Blog

Pragmatic Developers, Elegant Software

Project release and version management using gradle and git

leave a comment »

Two very useful Gradle plugins:

1. axion-release-plugin

This plugin derives project version from tags in git repository. I use following rules in my projects:

  • Start with default version 0.1.0-SNAPSHOT
  • Every release of master branch increments second digit
  • Production emergency fixes are done on a branch, which is created from the version tag. Such branch name must start with “hotfix-” prefix. Releasing this branch will increment 3rd digit.
  • Feature branches must have “topic-” prefix. They are never released, however their version includes feature name.

To check current project version run “gradle currentVersion”
To release the project run “gradle release”

2. gradle-nexus-plugin

This plugin adds ability to upload project artifacts to nexus repository. Simply run “gradle upload”.


buildscript {
    repositories {
        maven {url = ''}

plugins {
    id 'java'
    id '' version '1.3.4'
    id '' version '2.3.1'

scmVersion {
    versionIncrementer 'incrementMinor'
    branchVersionIncrementer = [
            'hotfix-.*' : { c -> c.currentVersion.incrementPatchVersion() }
    branchVersionCreator = [
            'topic-.*' : 'versionWithBranch'

group 'com.jpragma.myproject'
version = scmVersion.version

repositories {
    jcenter {url = ''}

dependencies {
    compile 'org.slf4j:slf4j-api:1.7.21'
    testCompile 'junit:junit:4.12'

nexus {
    sign = false
    repositoryUrl = 'http://localhost:8081/nexus/content/repositories/internal/'
    snapshotRepositoryUrl = 'http://localhost:8081/nexus/content/repositories/internal-snapshots/'

Written by isaaclevin

July 12, 2016 at 2:03 pm

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: