Gradle Version Catalogs, but reusable.
The catalogs are implemented as a (Settings) plugin for Gradle (7.4+). Currently it’s not available in the plugin repository. The recommended way to install the catalogs for now is using a Gradle Included Build:
- Add this repo to your project via git submodule or git-subrepo (recommended)
- Include it as composite build and apply the plugin. In your
settings.gradle(.kts), add the following:
pluginManagement {
includeBuild("libs/catalogs") // Path to the catalogs directory
}
plugins {
id("me.foreverigor.gradle.catalogue")
}- After a re-sync the dependencies should be now available in your build scripts
The full list of dependencies and their coordinates can be seen in Catalogs.kt
See Gradle guide Using a version catalog
After following the instructions above there are several ways to change the versions of the dependencies from the catalog.
You can specify the gradle version constraint directly:
dependencies {
implementation(org.slf4j.api) {
version { require("latest.release") }
}
}Or use custom version configuration through the plugin’s extension. In your settings.gradle(.kts) create a new versions object and tell the plugin to use it:
object MyVersions : CatalogVersions(
Slf4j = "1.7",
Picocli = latestRelease // Change values in constructor
) {
// Or override the properties (start writing to get IDE suggestions)
override var SpringBoot = withoutVersion
}
// let the plugin use your versions
gradleCatalogue {
versions = MyVersions // Not recommended to create instance here, better use a top-level val/ singleton
}A complete usage example is available in consumer. Note: all examples use Kotlin DSL, which is recommended.
- Gradle
version-catalogplugin link - refreshVersions – similar plugin with a list of dependencies, created before Gradle version catalogs were a thing
- Make it possible to specify custom catalog prefix
- API for configuring catalogs/ merging with existing ones
