From 97606578a493b34ecb55683de5a4bf9cd129eed3 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 15 Jan 2026 11:11:02 +0100 Subject: [PATCH] Updated gradle to 9.1.0 --- app/build.gradle.kts | 100 ++++++++++++----------- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 54 insertions(+), 48 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 456ccf4b5..63f56395d 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,7 +1,7 @@ import com.android.build.gradle.internal.tasks.factory.dependsOn import com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension import com.google.gms.googleservices.GoogleServicesPlugin -import java.io.ByteArrayOutputStream +import java.io.BufferedReader import java.io.FileInputStream import java.util.Properties @@ -31,57 +31,57 @@ if (firebaseCloudMessagingAvailable) { println("google-services.json not found, disabling CloudMessaging feature") } -var gitBranch = ByteArrayOutputStream() var gitVersion = "6.1.0-alpha" +var gitBranch = "" +try { + val gitDescribe = ProcessBuilder() + .command("git", "describe", "--abbrev=0") + .directory(project.rootDir) + .start() + .inputStream.bufferedReader().use(BufferedReader::readText) + .trim() + println("Git describe: $gitDescribe") -task("getGitVersion") { - val gitVersionStream = ByteArrayOutputStream() - val gitCommitsCount = ByteArrayOutputStream() - val gitCommitHash = ByteArrayOutputStream() + val gitCommitsCount = ProcessBuilder() + .command("git", "rev-list", "$gitDescribe..HEAD", "--count") + .directory(project.rootDir) + .start() + .inputStream.bufferedReader().use(BufferedReader::readText) + .trim() + println("Git commits count: $gitCommitsCount") - try { - exec { - commandLine("git", "describe", "--abbrev=0") - standardOutput = gitVersionStream - } - exec { - commandLine( - "git", - "rev-list", - gitVersionStream.toString().trim() + "..HEAD", - "--count", - ) - standardOutput = gitCommitsCount - } - exec { - commandLine("git", "rev-parse", "--short", "HEAD") - standardOutput = gitCommitHash - } - exec { - commandLine("git", "name-rev", "--name-only", "HEAD") - standardOutput = gitBranch - } + val gitCommitHash = ProcessBuilder() + .command("git", "rev-parse", "--short", "HEAD") + .directory(project.rootDir) + .start() + .inputStream.bufferedReader().use(BufferedReader::readText) + .trim() + println("Git commit hash: $gitCommitHash") - gitVersion = - if (gitCommitsCount.toString().trim().toInt() == 0) { - gitVersionStream.toString().trim() - } else { - gitVersionStream.toString().trim() + "." + - gitCommitsCount.toString() - .trim() + "+" + gitCommitHash.toString().trim() - } - println("Git version: $gitVersion") - } catch (e: Exception) { - println("Git not found [$e], using $gitVersion") - } - project.version = gitVersion + gitBranch = ProcessBuilder() + .command("git", "name-rev", "--name-only", "HEAD") + .directory(project.rootDir) + .start() + .inputStream.bufferedReader().use(BufferedReader::readText) + .trim() + println("Git branch name: $gitBranch") + + gitVersion = + if (gitCommitsCount.toInt() == 0) { + gitDescribe + } else { + "$gitDescribe.$gitCommitsCount+$gitCommitHash" + } +} catch (e: Exception) { + println("Git not found [$e], using $gitVersion") } -project.tasks.preBuild.dependsOn("getGitVersion") +println("Computed git version: $gitVersion") configurations { implementation { isCanBeResolved = true } } -task("linphoneSdkSource") { + +tasks.register("linphoneSdkSource") { doLast { configurations.implementation.get().incoming.resolutionResult.allComponents.forEach { if (it.id.displayName.contains("linphone-sdk-android")) { @@ -148,13 +148,16 @@ android { isDebuggable = true isJniDebuggable = true + val appVersion = gitVersion + val appBranch = gitBranch + println("Setting app version [$appVersion] app branch [$appBranch]") + resValue("string", "linphone_app_version", appVersion) + resValue("string", "linphone_app_branch", appBranch) if (useDifferentPackageNameForDebugBuild) { resValue("string", "file_provider", "$packageName.debug.fileprovider") } else { resValue("string", "file_provider", "$packageName.fileprovider") } - resValue("string", "linphone_app_version", gitVersion.trim()) - resValue("string", "linphone_app_branch", gitBranch.toString().trim()) resValue("string", "linphone_openid_callback_scheme", packageName) if (crashlyticsAvailable) { @@ -176,9 +179,12 @@ android { ) signingConfig = signingConfigs.getByName("release") + val appVersion = gitVersion + val appBranch = gitBranch + println("Setting app version [$appVersion] app branch [$appBranch]") + resValue("string", "linphone_app_version", appVersion) + resValue("string", "linphone_app_branch", appBranch) resValue("string", "file_provider", "$packageName.fileprovider") - resValue("string", "linphone_app_version", gitVersion.trim()) - resValue("string", "linphone_app_branch", gitBranch.toString().trim()) resValue("string", "linphone_openid_callback_scheme", packageName) if (crashlyticsAvailable) { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index db2508882..8c88e2b83 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Thu Jun 22 12:11:25 CEST 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists