From: Nathaniel Wesley Filardo Date: Sun, 22 Sep 2019 12:56:29 +0000 (+0100) Subject: build: add git description as resource string X-Git-Tag: release-1.4~11 X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=20f7dffc9c394e4109b3b76c1e6d9e1d41f1d4ce;p=acmetensortoys-ctfws-android build: add git description as resource string --- 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()}\"" } }