From 28cdd3984228bd2a66764cd6decc7c6af1777fc7 Mon Sep 17 00:00:00 2001 From: Dennis Guse Date: Sat, 27 Jul 2019 13:39:32 +0200 Subject: [PATCH] Automatic versioning (versionName and versionCode) using GIT. --- .idea/misc.xml | 2 +- build.gradle | 42 +++++++++++++++++++ src/main/AndroidManifest.xml | 10 ++--- .../dennisguse/opentracks/AboutActivity.java | 7 +++- .../content/ContentProviderUtils.java | 3 +- .../content/SearchEngineProvider.java | 4 +- .../content/TrackPointsColumns.java | 4 +- .../opentracks/content/TracksColumns.java | 4 +- .../opentracks/content/WaypointsColumns.java | 4 +- .../dennisguse/opentracks/util/FileUtils.java | 4 +- .../opentracks/util/SystemUtils.java | 17 ++++++-- src/main/res/layout/about.xml | 10 ++++- src/main/res/values/strings.xml | 7 +++- src/main/res/xml/settings.xml | 2 +- 14 files changed, 99 insertions(+), 21 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 37a750962..7bfef59df 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/build.gradle b/build.gradle index bc45106e7..b35b9f557 100644 --- a/build.gradle +++ b/build.gradle @@ -17,11 +17,43 @@ allprojects { } } +def getVersionCode = { -> + try { + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git', 'rev-list', 'HEAD', '--count' + 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; + } +} + android { compileSdkVersion 28 defaultConfig { applicationId "de.dennisguse.opentracks" + //Useful for debugging. + //versionCode getVersionCode() + //versionName getVersionName() + minSdkVersion 21 targetSdkVersion 28 @@ -29,10 +61,19 @@ android { } buildTypes { + debug { + applicationIdSuffix ".debug" + versionNameSuffix "-debug" + } + release { minifyEnabled true } } + + applicationVariants.all { variant -> + variant.resValue "string", "applicationId", variant.applicationId + } } dependencies { @@ -43,3 +84,4 @@ dependencies { androidTestImplementation 'androidx.test.ext:junit:1.1.1' testImplementation 'androidx.test:core:1.2.0' } + diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 96d1fcc33..e9716ee80 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -17,8 +17,8 @@ limitations under the License. xmlns:tools="http://schemas.android.com/tools" package="de.dennisguse.opentracks" android:installLocation="auto" - android:versionCode="100" - android:versionName="3.0.0"> + android:versionCode="2916" + android:versionName="v3.0.0"> @@ -186,18 +186,18 @@ limitations under the License. + + Project web page: %1$s - - Version: %1$s + + Version name: %1$s + + + Version code: %1$d OpenTracks is a fork of Google\'s MyTracks (discontinued in 2016). diff --git a/src/main/res/xml/settings.xml b/src/main/res/xml/settings.xml index cdc57c350..25410550c 100644 --- a/src/main/res/xml/settings.xml +++ b/src/main/res/xml/settings.xml @@ -38,7 +38,7 @@ limitations under the License. \ No newline at end of file