From 4eceafaaa5c62eb6d09b9f596b24a3bc9cbbb2f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Fri, 19 Dec 2014 18:11:25 +0100 Subject: [PATCH] Adding git ref to version when building locally. --- build.gradle | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/build.gradle b/build.gradle index 6cccb11bd..9be24adf4 100644 --- a/build.gradle +++ b/build.gradle @@ -29,8 +29,23 @@ version = "${config.oc.version}" group = "li.cil.oc" archivesBaseName = "OpenComputers" +def getGitRef() { + try { + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git', 'rev-parse', '--short', 'HEAD' + standardOutput = stdout + } + return stdout.toString().trim() + } catch (Throwable e) { + return "unknown" + } +} + if (System.getenv("BUILD_NUMBER") != null) version += ".${System.getenv("BUILD_NUMBER")}" +else + version += "-" + getGitRef() if (config.oc.subversion != null && config.oc.subversion != "") version += "-${config.oc.subversion}"