- Generate libs.version.toml (Version Catalogs) from existing Gradle build files.
- And replace the dependencies in the build files build.gradle(.kts) with the version catalog.
Example)
// Before
val awsSdkVersion = "2.3.4"
implementation("software.amazon.awssdk:sts:$awsSdkVersion")
implementation(group = "software.amazon.awssdk", name = "dynamodb", version = awsSdkVersion)
implementation("ch.qos.logback:logback-classic") // auto version
implementation("net.sf.json-lib:json-lib:2.3:jdk15") // classifierThis will be rewritten to:
// After
implementation(libs.software.amazon.awssdk.sts)
implementation(libs.software.amazon.awssdk.dynamodb)
implementation(libs.ch.qos.logback.logback.classic)
implementation(variantOf(libs.net.sf.json.lib.json.lib) { classifier = "jdk15" })with the generated version catalogs libs.versions.toml:
[versions]
awsSdkVersion = "2.3.4"
[dependencies]
software-amazon-awssdk-dynamodb = { group = "software.amazon.awssdk", name = "dynamodb", version.ref = "awsSdkVersion" }
software-amazon-awssdk-sts = { group = "software.amazon.awssdk", name = "sts", version.ref = "awsSdkVersion" }
ch-qos-logback-logback-classic = { group = "ch.qos.logback", name = "logback-classic", version = "1.5.18" }
net-sf-json-lib-json-lib = { group = "net.sf.json-lib", name = "json-lib", version = "2.3" }Note
In the above example, the latest version 1.5.18 is automatically selected for logback-classic since version must be specified in version catalog. If the command failed to decide latest version, it fallbacks to FIXME.
This behavior is enabled by default and can be disabled via --auto-latest=false option.
The autofilled version may be too new, so some manual intervention may be required.
- Download from https://github.com/exoego/gradle-version-catalogs-cli/releases
- Go to the repo where gradle is used
- Run the command below
./gradle-version-catalogs-cli generategradle-version-catalogs-cli generate [PATH]- Collects library versions in multiple build.gradle(.kts) and generates libs.versions.toml in
PATH/gradle. - If no
PATHis provided, the current working directory is used. - Some manual intervention may be required.
go get
make test
make build
./gradle-version-catalogs-cli generate ../path/to/gradle/project