Migrate Gradle project dependencies to version catalog

MSAL

Migrates Gradle project dependencies to use the version catalog feature. Supports migrating dependency declarations of various forms:

  • String notation: "group:artifact:version"
  • Map notation: group: 'group', name: 'artifact', version: 'version'
  • Property references: "group:artifact:$version" or "group:artifact:${version}"

The recipe will:

  • Create a gradle/libs.versions.toml file with version declarations
  • Replace dependency declarations with catalog references (e.g., libs.springCore)
  • Migrate version properties from gradle.properties to the version catalog
  • Preserve project dependencies unchanged

Note: If a version catalog already exists, the recipe will not modify it.

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

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