aboutsummaryrefslogtreecommitdiffstats
path: root/app/build.gradle
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2015-08-11 17:06:17 -0500
committerKenny Root <kenny@the-b.org>2015-08-11 17:09:19 -0500
commit75b510fb91e9c8a8d6a74a3dbce220bbdd316424 (patch)
treee75320a777cb60ca7c8c4397d7a1643866a4cda4 /app/build.gradle
parent958f7281fcc8c4e115254b21b8e0177f6500690e (diff)
downloadconnectbot-75b510fb91e9c8a8d6a74a3dbce220bbdd316424.tar.gz
connectbot-75b510fb91e9c8a8d6a74a3dbce220bbdd316424.tar.bz2
connectbot-75b510fb91e9c8a8d6a74a3dbce220bbdd316424.zip
Make sure version code is updated in strings
Diffstat (limited to 'app/build.gradle')
-rw-r--r--app/build.gradle27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 9219eb5..0913b4e 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -83,6 +83,33 @@ android {
}
}
+def getGitDescription = { ->
+ try {
+ def stdout = new ByteArrayOutputStream()
+ exec {
+ commandLine 'git', 'describe', '--tags', '--dirty'
+ standardOutput = stdout
+ }
+ return stdout.toString().trim()
+ } catch (ignored) {
+ return null;
+ }
+}
+
+// Insert the build number into strings.xml
+android.applicationVariants.all { variant ->
+ variant.mergeResources.doLast{
+ ext.env = System.getenv()
+ def buildNumber = getGitDescription()
+ if (buildNumber != null) {
+ File valuesFile = file("${buildDir}/intermediates/res/${variant.dirName}/values/values.xml")
+ String content = valuesFile.getText('UTF-8')
+ content = content.replaceAll(/\(working copy\)/, buildNumber)
+ valuesFile.write(content, 'UTF-8')
+ }
+ }
+}
+
if (project.hasProperty('keystorePassword')) {
android.signingConfigs.release.storeFile file(keystoreFile)
android.signingConfigs.release.storePassword keystorePassword