Skip to content

fix(kmp): derive the snapshot version without blocking the configuration cache - #1028

Open
jamesarich wants to merge 1 commit into
masterfrom
fix/kmp-configuration-cache
Open

fix(kmp): derive the snapshot version without blocking the configuration cache#1028
jamesarich wants to merge 1 commit into
masterfrom
fix/kmp-configuration-cache

Conversation

@jamesarich

@jamesarich jamesarich commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

packages/kmp currently cannot be built with --configuration-cache at all:

* What went wrong:
Configuration cache problems found in this build.

1 problem was found storing the configuration cache.
- Build file 'build.gradle.kts': external process started 'git describe --tags --abbrev=0'
> Starting an external process 'git describe --tags --abbrev=0' during configuration
  time is unsupported.

The VERSION_NAME fallback — which patch-bumps the latest git tag for local
snapshot builds — started git through ProcessBuilder directly. Gradle rejects
that outright under the configuration cache.

The change

Use providers.exec instead. It is the configuration-cache-aware equivalent:
the invocation is recorded as a configuration-cache input rather than being an
unsupported side effect.

Behaviour is unchanged, including both degradation paths:

  • the runCatching wrapper still covers a missing git binary;
  • isIgnoreExitValue = true keeps a tagless or shallow clone on the existing
    0.0.1-SNAPSHOT path instead of failing configuration.

Verification

Command Before After
./gradlew help --configuration-cache FAILED entry stored, then reused
./gradlew build --configuration-cache FAILED BUILD SUCCESSFUL, 79 tasks
derived version 2.7.27-SNAPSHOT 2.7.27-SNAPSHOT (identical)

Scope

This only unblocks the configuration cache — it does not enable it.
gradle.properties still leaves it off, so nothing changes for CI or for
anyone not passing the flag. Turning it on is a separate call, worth making
once there is Build Scan data to measure the win (see #1027).

Found while onboarding this repo to Develocity (#1027); the CC-reuse check in
that PR's verification could not be run because of this.

Summary by CodeRabbit

  • Bug Fixes
    • Improved version detection for tagless and shallow repository checkouts.
    • Builds now continue using fallback versioning when Git tag lookup is unavailable or unsuccessful.

…ion 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.
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow pull-request / build (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedAug 2, 2026, 11:45 PM

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8b20e25b-758d-43ea-ba70-c47b756f71af

📥 Commits

Reviewing files that changed from the base of the PR and between 6ceceae and 807b445.

📒 Files selected for processing (1)
  • packages/kmp/build.gradle.kts

📝 Walkthrough

Walkthrough

The build script now uses Gradle’s providers.exec to run git describe from the repository root. It records the command as a configuration-cache input and retains fallback behavior when Git returns no tag or a nonzero status.

Changes

Git version lookup

Layer / File(s) Summary
Provider-based Git tag lookup
packages/kmp/build.gradle.kts
The script replaces ProcessBuilder with providers.exec, preserves repository-root execution, and ignores nonzero exit statuses before applying the fallback version logic.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: deriving snapshot versions without blocking the configuration cache.
Description check ✅ Passed The description clearly covers the problem, solution, preserved fallback behavior, verification results, and scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/kmp-configuration-cache

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
packages/kmp/build.gradle.kts

Checkov skipped this file: it was unavailable in the sandbox worktree

🔧 detekt (1.23.8)
packages/kmp/build.gradle.kts

Exception in thread "main" com.beust.jcommander.ParameterException: Provided path 'packages/kmp/build.gradle.kts' does not exist!
at io.gitlab.arturbosch.detekt.cli.ExistingPathConverter.convert(ArgumentConverters.kt:16)
at io.gitlab.arturbosch.detekt.cli.ExistingPathConverter.convert(ArgumentConverters.kt:11)
at io.gitlab.arturbosch.detekt.cli.DetektInputPathConverter$DefaultImpls.convert$lambda$1(ArgumentConverters.kt:31)
at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:210)
at kotlin.sequences.SequencesKt___SequencesKt.toList(_Sequences.kt:815)
at io.gitlab.arturbosch.detekt.cli.DetektInputPathConverter$DefaultImpls.convert(ArgumentConverters.kt:32)
at io.gitlab.arturbosch.detekt.cli.MultipleExistingPathConverter.convert(ArgumentConverters.kt:41)
at io.gitlab.arturbosch.detekt.cli.CliArgs.inputPaths_delegate$lambda$0(CliArgs.kt:193)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at io.gitlab.arturbosch.detekt.cli.CliArgs.getInputPaths(CliArgs.kt:192)
at io.gitlab.arturbosch.detekt.cli.SpecKt.createSpec$lambda$15$lambda$1(Spec.kt:18)
at io.github.detekt.tooling.dsl.ProcessingSpecBuilder.project(ProcessingSpecBuilder.kt:37)
at io.gitlab.arturbosch.detekt.cli.SpecKt.createSpec$lambda$15(Spec.kt:16)
at io.github.detekt.tooling.dsl.ProcessingSpecBuilderKt.processingSpec(ProcessingSpecBuilder.kt:15)
at io.github.detekt.tooling.api.spec.ProcessingSpec$Companion.invoke(ProcessingSpec.kt:23)
at io.gitlab.arturbosch.detekt.cli.SpecKt.createSpec(Spec.kt:9)
at io.gitlab.arturbosch.detekt.cli.runners.Runner.(Runner.kt:20)
at io.gitlab.arturbosch.detekt.cli.CliRunner.run(CliRunner.kt:31)
at io.gitlab.arturbosch.detekt.cli.CliRunner.run(CliRunner.kt:14)
at io.gitlab.arturbosch.detekt.cli.Main.main(Main.kt:20)


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant