From 1fe1e11e0e70daffd4fdb5e24e9784458b8d248c Mon Sep 17 00:00:00 2001 From: Tim Mutton Date: Thu, 6 Apr 2017 19:53:25 +1000 Subject: [PATCH] Use try/catch with logging for version number --- Source/Android/app/build.gradle | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Source/Android/app/build.gradle b/Source/Android/app/build.gradle index ea7165d4d5..3f2b90bc6d 100644 --- a/Source/Android/app/build.gradle +++ b/Source/Android/app/build.gradle @@ -1,5 +1,3 @@ -import org.apache.tools.ant.taskdefs.condition.Os - apply plugin: 'com.android.application' android { @@ -96,12 +94,15 @@ dependencies { } def getVersion() { - String result - if(Os.isFamily(Os.FAMILY_WINDOWS)) { - result = 'cmd /c git describe --always --long'.execute([], project.rootDir).text - } else { - result = 'git describe --always --long'.execute([], project.rootDir).text + def versionNumber = '0.0' + + try { + versionNumber = 'git describe --always --long'.execute([], project.rootDir).text + .trim() + .replaceAll(/(-0)?-[^-]+$/, "") + } catch (Exception e) { + logger.error('Cannot find git, defaulting to dummy version number') } - return result.trim().replaceAll(/(-0)?-[^-]+$/, "") + return versionNumber }