From 807b4457ccb19d70d667c03ba08524f882942dd6 Mon Sep 17 00:00:00 2001 From: James Rich Date: Sun, 2 Aug 2026 18:45:24 -0500 Subject: [PATCH] fix(kmp): derive the snapshot version without blocking the configuration cache packages/kmp cannot be built with --configuration-cache: - Build file 'build.gradle.kts': external process started 'git describe --tags --abbrev=0' > Starting an external process during configuration time is unsupported. The version fallback started git via ProcessBuilder directly, which Gradle rejects outright under the configuration cache. Switch to providers.exec, which records the invocation as a configuration-cache input instead. Behaviour is unchanged. The runCatching wrapper still covers a missing git binary, and isIgnoreExitValue keeps a tagless or shallow clone on the existing 0.0.1-SNAPSHOT path rather than failing the build. Verified that the derived version is identical before and after (2.7.27-SNAPSHOT). ./gradlew help --configuration-cache entry stored, then reused ./gradlew build --configuration-cache BUILD SUCCESSFUL, 79 tasks This only unblocks the configuration cache; it does not enable it. Turning it on in gradle.properties is a separate call. --- packages/kmp/build.gradle.kts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/kmp/build.gradle.kts b/packages/kmp/build.gradle.kts index d48c6d25..1f4177ac 100644 --- a/packages/kmp/build.gradle.kts +++ b/packages/kmp/build.gradle.kts @@ -12,12 +12,21 @@ version = providers.gradleProperty("VERSION_NAME").orElse( // derive a snapshot version by patch-bumping the latest git tag. Any // failure — git missing, shallow/tagless clone, or an unexpected tag // format — degrades to 0.0.1-SNAPSHOT instead of breaking configuration. + // + // Uses providers.exec rather than ProcessBuilder: starting a process + // directly at configuration time is rejected outright under the + // configuration cache ("external process started 'git describe …' … + // is unsupported"), which made this build impossible to run with + // --configuration-cache. providers.exec records the invocation as a + // configuration-cache input instead. val tag = runCatching { - val process = ProcessBuilder("git", "describe", "--tags", "--abbrev=0") - .directory(rootDir) - .start() - val out = process.inputStream.bufferedReader().readText().trim() - if (process.waitFor() == 0) out else "" + providers.exec { + workingDir = rootDir + commandLine("git", "describe", "--tags", "--abbrev=0") + // A tagless or shallow clone exits non-zero; fall through to + // the 0.0.0 defaults below rather than failing the build. + isIgnoreExitValue = true + }.standardOutput.asText.get().trim() }.getOrDefault("") val parts = tag.removePrefix("v").split(".")