Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions packages/kmp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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(".")
Expand Down