From ee4d71f8eb237cc7ee66b61f2e7a0134b1e46b23 Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Sat, 14 Jul 2018 17:40:17 +0200 Subject: [PATCH] Use git for verison code & text --- shell/android-studio/app/build.gradle | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/shell/android-studio/app/build.gradle b/shell/android-studio/app/build.gradle index 19ceeb183..d819b779a 100644 --- a/shell/android-studio/app/build.gradle +++ b/shell/android-studio/app/build.gradle @@ -1,6 +1,23 @@ apply plugin: 'com.android.application' apply plugin: 'com.github.triplet.play' +def getVersionCode = { -> + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git', 'rev-list', '--count', 'HEAD' + standardOutput = stdout + } + return Integer.parseInt(stdout.toString().trim()) +} + +def getVersionName = { -> + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git', 'describe', '--always' + standardOutput = stdout + } + return stdout.toString().trim() +} android { compileSdkVersion 25 @@ -10,8 +27,8 @@ android { applicationId "com.reicast.emulator" minSdkVersion 16 targetSdkVersion 25 - versionCode="7" - versionName="r7" + versionCode getVersionCode() + versionName getVersionName() vectorDrawables.useSupportLibrary = true ndk {