From 7fc262acf33df88dc62a3353f1e60627ac7b2c19 Mon Sep 17 00:00:00 2001 From: Yves Noirjean <ynoir@bsse-vpn-247.ethz.ch> Date: Thu, 26 Oct 2017 13:57:47 +0200 Subject: [PATCH] getting git tag as project.ext.versionNumber --- gradle/javaproject.gradle | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gradle/javaproject.gradle b/gradle/javaproject.gradle index b829be74746..beb28df63e4 100644 --- a/gradle/javaproject.gradle +++ b/gradle/javaproject.gradle @@ -150,7 +150,12 @@ def calculateBuildInfo() { } else if (isGitProject()) { def gitlogoutput = execute_working_dir('git', ['log', '-1', '--format=%at'], '../' + project.name) project.ext.revisionNumber = Integer.parseInt(gitlogoutput[0]) - project.ext.versionNumber = 'SNAPSHOT' + def tag = 'git describe --tags'.execute().text.trim() + if (tag == null || tag.isEmpty()) { + project.ext.versionNumber = 'SNAPSHOT' + } else { + project.ext.versionNumber = tag + } } else { project.ext.revisionNumber = 1 project.ext.versionNumber = 'SNAPSHOT' -- GitLab