feat(matrix): Fetch AGP<->Kotlin compat dynamically#1166
Merged
Conversation
Replace the static gradleToKotlin dict with a fetch of the AGP/Kotlin compatibility table from developer.android.com/build/kotlin-support. For each AGP version we now pick the highest Kotlin whose required AGP is <= ours, which is a more direct semantic fit and also catches new Kotlin minors automatically. The existing Kotlin->min-Gradle floor check (sourced from kotlinlang.org) stays in place. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
The developer.android.com/build/kotlin-support table lists upcoming Kotlin minors before they ship (e.g. Kotlin 2.4 with AGP 9.1.0 while only 2.4.0-Beta* is on Maven Central). Resolve each Kotlin minor to its latest stable patch by reading kotlin-stdlib's maven-metadata.xml and drop rows whose minor has no stable release yet, so the generated matrix never references an unpublished version. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
KSP 2.1.0-1.0.29 is pinned to Kotlin compiler 2.1.0 and fails with "ksp-2.1.0-1.0.29 is too old for kotlin-2.3.21" when the test matrix runs the android-instrumentation-sample against newer Kotlin versions. Bump to 2.3.7, which is the latest KSP2 release — KSP2 is decoupled from the Kotlin compiler version and works across the Kotlin versions the matrix now picks from developer.android.com/build/kotlin-support. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The pinned KSP (2.1.0-1.0.29, KSP1) is bound to the Kotlin 2.1 compiler and fails with "ksp is too old for kotlin-X" when the test matrix picks newer Kotlin versions from developer.android.com/build/kotlin-support. Bumping KSP directly breaks the default build because KSP2 requires Kotlin language version 2.0+, but the default Kotlin in Dependencies.kt is 1.8.20. Intercept plugin resolution in settings.gradle.kts: when VERSION_KOTLIN is set (i.e. the matrix is driving the build), use KSP2 2.3.7, which is decoupled from the Kotlin compiler. Otherwise leave the pinned KSP1 in place so default / pre-merge builds keep working. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The settings.gradle.kts resolutionStrategy override didn't work because plugin-alias requests through the version catalog bypass it — Gradle rejected the rewrite with "the plugin is already on the classpath with a different version". Switch to the same pattern the other Kotlin plugins use: a `BuildPluginsVersion.KSP` field sourced from VERSION_KOTLIN (KSP2 2.3.7 when Kotlin 2.x, KSP1 2.1.0-1.0.29 otherwise), applied via `version BuildPluginsVersion.KSP` on both the root `apply false` and the sample's plugins block. Verified locally that both default builds (Kotlin 1.8.20, KSP1) and the matrix path (VERSION_KOTLIN=2.3.21, KSP2) resolve and run `kspStagingReleaseKotlin` successfully. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two related bugs in the AGP -> Kotlin lookup:
1. `agpVersion >= minAgp` evaluates to false for pre-release AGP with
the same major.minor.patch as a stable minAgp (semver rule:
9.3.0-alpha01 < 9.3.0). Strip the pre-release identifier before
the comparison so a row that should match isn't skipped.
2. `maxByOrNull { it.first }` picks the highest minAgp, not the
highest Kotlin. Works by coincidence today under monotonic data
but breaks on ties (e.g. Kotlin 1.4 and 1.5 both require AGP 7.0).
Switch to `it.second` to select by Kotlin version directly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Code cleanup from review:
- Add fetchGooglesourceText() and parseVersionOrNull() helpers to
collapse the repeated URL-base64-decode and try/catch-parse patterns
across six call sites in the compat fetchers.
- Parse the Kotlin major as an Int in BuildPluginsVersion.KSP instead
of matching `startsWith("2.")`, so a future Kotlin "20.x" won't be
misclassified as Kotlin 2.x.
No behavior change; matrix output verified identical.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8bf5535. Configure here.
runningcode
approved these changes
Apr 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

#skip-changelog
Replace the static
gradleToKotlindict inscripts/generate-compat-matrix.main.ktswith a fetch of the AGP ↔ Kotlin compatibility table from developer.android.com/build/kotlin-support. For each AGP version in the CI matrix we now pick the highest Kotlin whose required AGP is ≤ ours, which is a more direct semantic fit than the previous Gradle→Kotlin hand-picked map and also catches new Kotlin minors automatically.Follow-up to #1165, which switched the AGP↔Gradle source.
The existing Kotlin→min-Gradle floor check (sourced from kotlinlang.org via
fetchKotlinGradleCompatibility) stays in place, so if the chosen Kotlin needs a newer Gradle than AGP does, we still bump Gradle up.Verified output locally against the four AGP versions the matrix generator picks today:
Gradle versions are unchanged.