From 01a342582c6635a3ea8b2030f7698423b11623c7 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Tue, 24 Feb 2026 12:11:21 +0100 Subject: [PATCH] Fix runGit to use ProcessBuilder for AGP 9 compatibility --- app/build.gradle.kts | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 3597a05..8114035 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,5 +1,3 @@ -import java.io.ByteArrayOutputStream - plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.compose) @@ -9,6 +7,14 @@ plugins { } // ── Git-based versioning ──────────────────────────────────── +fun runGit(vararg args: String): String = try { + val proc = ProcessBuilder("git", *args) + .directory(rootProject.projectDir) + .redirectErrorStream(true) + .start() + proc.inputStream.bufferedReader().readText().trim().also { proc.waitFor() } +} catch (_: Exception) { "" } + // Version name from latest git tag (e.g. v0.1.0 -> "0.1.0") fun gitVersionName(): String = runGit("describe", "--tags", "--abbrev=0") .removePrefix("v") @@ -23,23 +29,8 @@ fun buildNumber(): Int { fun gitShortHash(): String = runGit("rev-parse", "--short", "HEAD") .ifEmpty { "unknown" } -// Display: "0.1.0+6.abc1234" -fun gitDisplayVersion(): String { - val base = gitVersionName() - val build = buildNumber() - val hash = gitShortHash() - return "$base+$build.$hash" -} - -fun runGit(vararg args: String): String = try { - val out = ByteArrayOutputStream() - project.exec { - commandLine("git", *args) - standardOutput = out - isIgnoreExitValue = true - } - out.toString().trim() -} catch (_: Exception) { "" } +// Display: "0.1.0+7.abc1234" +fun gitDisplayVersion(): String = "${gitVersionName()}+${buildNumber()}.${gitShortHash()}" // ─────────────────────────────────────────────────────────────