diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/build.gradle | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/app/build.gradle b/app/build.gradle index cb80b6c..2732c04 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,3 +1,31 @@ +def getVersionCode = { -> + try { + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git', 'rev-list', '--first-parent', '--count', 'master' + standardOutput = stdout + } + return Integer.parseInt(stdout.toString().trim()) + } + catch (ignored) { + return -1; + } +} + +def getVersionName = { -> + try { + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git', 'describe', '--tags', '--dirty' + standardOutput = stdout + } + return stdout.toString().trim() + } + catch (ignored) { + return null; + } +} + buildscript { repositories { mavenCentral() @@ -25,8 +53,10 @@ android { applicationId 'io.trygvis.soilmoisture' minSdkVersion 19 targetSdkVersion 19 - versionCode 1 - versionName "1.0" + versionCode getVersionCode() + versionName getVersionName() + + println("versionCode=$versionCode, versionName=$versionName") } buildTypes { release { @@ -39,6 +69,8 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } lintOptions { + // The linter errors out with an NPE. + checkReleaseBuilds false abortOnError false } productFlavors { |