From 20f7dffc9c394e4109b3b76c1e6d9e1d41f1d4ce Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Sun, 22 Sep 2019 13:56:29 +0100 Subject: [PATCH] build: add git description as resource string --- mobile/build.gradle | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mobile/build.gradle b/mobile/build.gradle index c7a2d43..f117652 100644 --- a/mobile/build.gradle +++ b/mobile/build.gradle @@ -1,5 +1,15 @@ apply plugin: 'com.android.application' +// See stackoverflow.com/questions/28498688 +def makeGitDescription = { + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git', 'describe', '--always' + standardOutput = stdout + } + return stdout.toString().trim() +} + android { compileSdkVersion 28 defaultConfig { @@ -16,12 +26,14 @@ android { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + buildConfigField "String", "gitDescription", "\"${makeGitDescription()}\"" } debug { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' // Cam: testing on hardware, whee debuggable true + buildConfigField "String", "gitDescription", "\"${makeGitDescription()}\"" } } -- 2.50.1