Skip to content

Commit 4c4ab7f

Browse files
romtsnclaude
andcommitted
fix(matrix): Strip AGP pre-release and select Kotlin by value
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>
1 parent 059375b commit 4c4ab7f

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

scripts/generate-compat-matrix.main.kts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,14 @@ class GenerateMatrix : CliktCommand() {
102102
put("agp", agpVersion.toString())
103103
val gradle = entry.value
104104

105-
// Pick the latest Kotlin whose required AGP <= this AGP
105+
// Pick the latest Kotlin whose required AGP <= this AGP. Strip the pre-release
106+
// identifier so 9.3.0-alpha01 isn't treated as < 9.3.0 by semver rules, which would
107+
// skip a row that should match.
108+
val agpStable = Version(agpVersion.major, agpVersion.minor, agpVersion.patch)
106109
val kotlinVersion =
107110
agpToKotlin
108-
.filter { (minAgp, _) -> agpVersion >= minAgp }
109-
.maxByOrNull { it.first }
111+
.filter { (minAgp, _) -> agpStable >= minAgp }
112+
.maxByOrNull { it.second }
110113
?.second
111114

112115
// Floor: if the chosen Kotlin requires a newer Gradle than AGP does, bump Gradle up

0 commit comments

Comments
 (0)