]> hydra-www.ietfng.org Git - acmetensortoys-ctfws-android/commitdiff
build: add git description as resource string
authorNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sun, 22 Sep 2019 12:56:29 +0000 (13:56 +0100)
committerNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sun, 22 Sep 2019 14:35:53 +0000 (15:35 +0100)
mobile/build.gradle

index c7a2d43a7d3e9b9dba1e4762bf343d2ae6814403..f11765287bec3f22acc3e6e6545ac667ac61d782 100644 (file)
@@ -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()}\""
         }
     }