Use localGroovy() in a Gradle plugin project

MSAL

A Gradle plugin project compiles against the Gradle API, which brings Gradle's own Groovy with it, so a Groovy declared in the build as well is redundant. Where the two are different majors it is worse than redundant: Gradle 9 brings Groovy 4, and a project that declares Groovy 2 or 3 fails to compile with "Conflicting module versions. Module [groovy-nio] is loaded in version 2.5.4 and you are trying to load version 4.0.33". This recipe replaces such a declaration with localGroovy(), which is Gradle's own Groovy named explicitly, in a project that applies java-gradle-plugin. A declaration of Groovy 4 or later is left alone, since it does not conflict, and so is a project that is not a plugin project, where Gradle's Groovy is not on the classpath to begin with and localGroovy() would pin the project to whichever Gradle runs it. A module of the distribution, such as groovy-json, is left alone as well: localGroovy() is the whole distribution and swapping one module for it would widen what the project depends on. See the Gradle userguide.

org.openrewrite.gradle.migrate.artifacts.UseLocalGroovy
mod run . --recipe=org.openrewrite.gradle.migrate.artifacts.UseLocalGroovy

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.