From bfc7a386eef4ac7a022dd1292b6144a85d32876a Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 16 May 2019 12:18:57 +0200 Subject: [PATCH] Improved use of git version --- app/build.gradle | 49 +++++++++---------- .../linphone/activities/AboutActivity.java | 2 +- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 33d816dd2..a6de6d2c0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,6 +23,25 @@ static def isLocalAarAvailable() { return isLocalDebugAarAvailable() || isLocalReleaseAarAvailable() } +task getGitVersion() { + def gitVersion = "4.1" + def gitVersionStream = new ByteArrayOutputStream() + + def result = exec { + def command = "git describe --always" + ignoreExitValue = true + executable "bash" args "-l", "-c", command + standardOutput = gitVersionStream + } + if (result.getExitValue() == 0) { + gitVersion = gitVersionStream.toString().trim() + println("Git version: " + gitVersion) + } else { + println("Git not found") + } + project.version = gitVersion +} + ///// Exclude Files ///// def excludeFiles = [] @@ -41,29 +60,6 @@ excludePackage.add('**/libopenh264**') excludePackage.add('**/**tester**') excludePackage.add('**/LICENSE.txt') - -def gitVersion = new ByteArrayOutputStream() - -task getGitVersion { - doLast { - def result = exec { - def command = "git describe --always" - ignoreExitValue = true - executable "bash" args "-l", "-c", command - standardOutput = gitVersion - } - if (result.getExitValue() == 0) { - gitVersion = gitVersion.toString().trim() - println("Git version: " + gitVersion) - } else { - gitVersion = "unknown" - println("Git not found") - } - } -} - -project.tasks['preBuild'].dependsOn 'getGitVersion' - ///////////////////////// repositories { @@ -73,6 +69,8 @@ repositories { } } +project.tasks['preBuild'].dependsOn 'getGitVersion' + android { lintOptions { abortOnError false @@ -83,7 +81,7 @@ android { minSdkVersion 21 targetSdkVersion 28 versionCode 4124 - versionName "4.1" + versionName "${project.version}" applicationId getPackageName() multiDexEnabled true manifestPlaceholders = [linphone_address_mime_type:"vnd.android.cursor.item/vnd." + getPackageName() + ".provider.sip_address"] @@ -91,7 +89,7 @@ android { applicationVariants.all { variant -> variant.outputs.all { - outputFileName = "linphone-android-${variant.buildType.name}-${gitVersion.toString().trim()}.apk" + outputFileName = "linphone-android-${variant.buildType.name}-${project.version}.apk" } } @@ -126,7 +124,6 @@ android { applicationIdSuffix ".debug" debuggable true jniDebuggable true - versionNameSuffix '-debug' resValue "string", "sync_account_type", getPackageName() + ".sync" resValue "string", "file_provider", getPackageName() + ".provider" diff --git a/app/src/main/java/org/linphone/activities/AboutActivity.java b/app/src/main/java/org/linphone/activities/AboutActivity.java index 0b1c440f8..e2502eada 100644 --- a/app/src/main/java/org/linphone/activities/AboutActivity.java +++ b/app/src/main/java/org/linphone/activities/AboutActivity.java @@ -80,7 +80,7 @@ public class AboutActivity extends MainActivity { aboutVersion.setText( String.format( getString(R.string.about_version), - BuildConfig.VERSION_NAME + " (" + BuildConfig.VERSION_CODE + ")")); + BuildConfig.VERSION_NAME + " (" + BuildConfig.BUILD_TYPE + ")")); TextView privacyPolicy = findViewById(R.id.privacy_policy_link); privacyPolicy.setOnClickListener(