From e21614caf88a1894ebd90e7b651aae1b5befb1f6 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Tue, 9 Apr 2019 16:03:39 +0100 Subject: [PATCH] Fix build number not showing in jar --- build.gradle | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index 853a547fe..78ad46d5b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import org.ajoberstar.grgit.Grgit + buildscript { repositories { mavenLocal() @@ -22,7 +24,7 @@ buildscript { plugins { id 'net.minecrell.licenser' version '0.4.1' apply false - id "org.ajoberstar.grgit" version "2.3.0" + id "org.ajoberstar.grgit" version "3.1.1" } apply plugin: 'java' @@ -41,20 +43,15 @@ def revision = "" def buildNumber = "" def date = "" ext { - try { - git = org.ajoberstar.grgit.Grgit.open(file(".git")) - date = git.head().date.format("yy.MM.dd") - revision = "-${git.head().abbreviatedId}" - index = -1960; // Offset to match CI - parents = git.head().parentIds; - for (; parents != null && !parents.isEmpty(); index++) { - commit = git.getResolve().toCommit(parents.get(0)); - parents = commit.getParentIds() - } - buildNumber = "${index}" - } catch (Throwable ignore) { - revision = "-unknown" + git = Grgit.open(dir: '.git') + date = git.head().getDate().format("yy.MM.dd") + revision = "-${git.head().abbreviatedId}" + parents = git.head().parentIds; + index = -2111; // Offset to match CI + for (; parents != null && !parents.isEmpty(); index++) { + parents = git.getResolve().toCommit(parents.get(0)).getParentIds() } + buildNumber = "${index}" } if ( project.hasProperty("lzNoVersion") ) { // gradle build -PlzNoVersion