From 8a5e173a744a213346c97625f22236584975ef54 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 29 May 2019 22:17:37 +0200 Subject: [PATCH] Fix building when not running in a git repo --- build.gradle | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 641414ea..1f764a5e 100644 --- a/build.gradle +++ b/build.gradle @@ -33,12 +33,14 @@ targetCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8 ext { - revision = grgit.log().size() - hash = grgit.head().abbreviatedId - if (file('.git/shallow').exists()) { - // don't clone with --depth - revision = -1 - hash += " shallow" + if (grgit == null) { + revision = "nogit" + } else { + revision = "${grgit.log().size()}-${grgit.head().abbreviatedId}" + if (file('.git/shallow').exists()) { + // don't clone with --depth + revision = "-1-${shallow}" + } } } @@ -48,7 +50,7 @@ if (project.release != 'RELEASE') { version += "-${project.release}" } if (project.release == 'SNAPSHOT') { - version += "-${project.revision}-${project.hash}" + version += "-${project.revision}" } group = project.group