diff options
author | jkoan <jkoan@users.noreply.github.com> | 2018-08-12 19:32:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-12 19:32:13 +0200 |
commit | f522845075fac87d5cfe8acb7dc643c58ef47e51 (patch) | |
tree | 27e1b4955e0b2035104a158d2b816accfc3e5d1d | |
parent | 584e7c98676c50fa4a9deca5497facc6f27e3d60 (diff) | |
download | navit-f522845075fac87d5cfe8acb7dc643c58ef47e51.tar.gz |
Fix Android apk VersionCode (#633)
* Create git-scm-version.gradle
* Update build.gradle
* Update git-scm-version.gradle
* Update build.gradle
* Update git-scm-version.gradle
* Update git-scm-version.gradle
* Update git-scm-version.gradle
* Update git-scm-version.gradle
* Update git-scm-version.gradle
* Update git-scm-version.gradle
* Update git-scm-version.gradle
* chnage to get release tags
-rw-r--r-- | gradle/scripts/git-scm-version.gradle | 24 | ||||
-rw-r--r-- | navit/android/build.gradle | 5 |
2 files changed, 27 insertions, 2 deletions
diff --git a/gradle/scripts/git-scm-version.gradle b/gradle/scripts/git-scm-version.gradle new file mode 100644 index 000000000..a0d518a86 --- /dev/null +++ b/gradle/scripts/git-scm-version.gradle @@ -0,0 +1,24 @@ +//THX to https://proandroiddev.com/configuring-android-project-version-name-code-b168952f3323 + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'org.ajoberstar:grgit:2.3.0' + } +} + +import org.ajoberstar.grgit.Grgit +import java.time.format.DateTimeFormatter + +ext { + git = Grgit.open(currentDir: projectDir) + gitVersionName = git.describe(match: ["v[0-9.rc]*"]) + gitVersionCode = Integer.parseInt(DateTimeFormatter.ofPattern("yyMMddhhmm").format(git.head().dateTime)) +} + +task printVersion() { + println("Version Name: $gitVersionName") + println("Version Code: $gitVersionCode") +} diff --git a/navit/android/build.gradle b/navit/android/build.gradle index ca9dab255..e2e42bc80 100644 --- a/navit/android/build.gradle +++ b/navit/android/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'com.android.application' +apply from: "$project.rootDir/gradle/scripts/git-scm-version.gradle" apply plugin: 'checkstyle' android { @@ -8,8 +9,8 @@ android { applicationId "org.navitproject.navit" minSdkVersion 9 targetSdkVersion 27 - versionCode 1 - versionName "1.0" + versionCode gitVersionCode + versionName gitVersionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" ndk { // need for now for 'x86_64' and , 'armeabi' and , 'arm64-v8a' abiFilters 'x86', 'armeabi-v7a' |