From e382869a1b0167df6db53880e10e21445a389cc2 Mon Sep 17 00:00:00 2001 From: Daisuke Miyamoto Date: Sat, 26 Nov 2016 19:06:47 +0900 Subject: [PATCH] Add auto versioning build feature --- build.gradle | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 8ae99aee..96d862de 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ buildscript { classpath "com.gradle.publish:plugin-publish-plugin:0.9.1" classpath "com.diffplug.gradle.spotless:spotless:1.3.3" classpath "de.thetaphi:forbiddenapis:2.2" - classpath 'org.ajoberstar:grgit:1.1.0' + classpath 'org.ajoberstar:grgit:1.7.0' classpath "de.aaschmid:gradle-cpd-plugin:1.0" } } @@ -28,7 +28,21 @@ defaultTasks "clean", "build" // ======== deployment options (dispatched on group name) ======== group = "jp.classmethod.aws" -version = "0.32-SNAPSHOT" + +ext { + git = org.ajoberstar.grgit.Grgit.open(file('.')) + describedCommit = git.describe().toString().trim() +} + +version = describedCommit + + (describedCommit.matches(".*-[0-9]+-g[0-9a-f]{7}") ? "-SNAPSHOT" : "") + + (git.status().isClean() ? "" : "+dirty") + +task showVersion { + doLast { + println version + } +} sourceCompatibility = targetCompatibility = 1.8