You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
org.openrewrite.gradle.AddDependency makes no changes to build.gradle.kts
when a gradle/libs.versions.toml is present in the project, only when the
embedded Gradle daemon is 9.x. The same recipe invocation against the same
inputs produces the expected edit on Gradle 8.14.3.
The catalog branch of AddDependency (which inserts libs.foo into the
build script) appears to be the affected path — inline dependency
declarations work fine on Gradle 9.
Reproducer
Minimal RewriteTest, no other recipes involved. The catalog is pre-seeded
with the entry, so the test is purely exercising AddDependency's
build-script-editing path.
So the trigger is specifically: Gradle 9.x daemon andlibs.versions.toml
present. Inline dependency declarations are unaffected on Gradle 9.
Versions tested
openrewrite-core: 8.81.3 (latest at time of filing). Also reproduces
with 8.81.2. (8.81.1 and earlier reject the -b flag on Gradle 9; the isGradle9OrLater gate landed in 8.81.2.)
runtime. That was fixed by the K2 upgrade in Upgrade rewrite-kotlin to Kotlin 2 compiler (K2) #6766 (kotlin-compiler-embeddable 2.2.0). With that fix in place, the inline case now works on JDK 25 +
Gradle 9 — but the catalog case still fails, regardless of JDK launcher
version, whenever the daemon is Gradle 9.x. The repro above runs on JDK 21
launcher specifically to rule out any K2 / Kotlin-parsing involvement.
Hypotheses
Either the Tooling API in Gradle 9 returns a GradleProject model whose
catalog metadata isn't shaped the way AddDependency's catalog-detection
branch expects, or rewrite-gradle's build-script editing assumes a
Gradle 8 AST shape that no longer holds. Happy to gather more diagnostic
info (e.g., dump the GradleProject marker under each daemon) if useful.
Summary
org.openrewrite.gradle.AddDependencymakes no changes tobuild.gradle.ktswhen a
gradle/libs.versions.tomlis present in the project, only when theembedded Gradle daemon is 9.x. The same recipe invocation against the same
inputs produces the expected edit on Gradle 8.14.3.
The catalog branch of
AddDependency(which insertslibs.foointo thebuild script) appears to be the affected path — inline dependency
declarations work fine on Gradle 9.
Reproducer
Minimal
RewriteTest, no other recipes involved. The catalog is pre-seededwith the entry, so the test is purely exercising
AddDependency'sbuild-script-editing path.
Result on Gradle 9.0.0 / 9.4.1 daemon:
Result on Gradle 8.14.3 daemon: passes.
Bisect
openrewrite-corepinned to 8.81.3 throughout. JDK 21 launcherSo the trigger is specifically: Gradle 9.x daemon and
libs.versions.tomlpresent. Inline dependency declarations are unaffected on Gradle 9.
Versions tested
openrewrite-core: 8.81.3 (latest at time of filing). Also reproduceswith 8.81.2. (8.81.1 and earlier reject the
-bflag on Gradle 9; theisGradle9OrLatergate landed in 8.81.2.)Gradle daemon: 9.0.0, 9.4.1 (both fail), 8.14.3 (passes).
JDK launcher: 21. (JDK 25 launcher also reproduces but adds the noise
OS: macOS, arm64.
Not a duplicate of Compatibilty of Java25 and build.gradle.kts #6132
Compatibilty of Java25 and build.gradle.kts #6132 was the JDK 25 launcher case —
build.gradle.ktscouldn't be parsedbecause the bundled Kotlin compiler (1.9.x) didn't support JDK 25 as a
runtime. That was fixed by the K2 upgrade in Upgrade rewrite-kotlin to Kotlin 2 compiler (K2) #6766 (
kotlin-compiler-embeddable 2.2.0). With that fix in place, the inline case now works on JDK 25 +Gradle 9 — but the catalog case still fails, regardless of JDK launcher
version, whenever the daemon is Gradle 9.x. The repro above runs on JDK 21
launcher specifically to rule out any K2 / Kotlin-parsing involvement.
Hypotheses
Either the Tooling API in Gradle 9 returns a
GradleProjectmodel whosecatalog metadata isn't shaped the way
AddDependency's catalog-detectionbranch expects, or
rewrite-gradle's build-script editing assumes aGradle 8 AST shape that no longer holds. Happy to gather more diagnostic
info (e.g., dump the
GradleProjectmarker under each daemon) if useful.