Easily use any BOM as a Gradle Version Catalog.
First, add your BOM dependencies to your version catalog
libs.versions.toml
[versions]
spring = "3.2.0"
aws = "2.22.0"
[libraries]
awsBom = { group = "software.amazon.awssdk", name = "bom", version.ref = "aws" }
springBootDependencies = { group = "org.springframework.boot", name = "spring-boot-dependencies", version.ref = "spring" }
Then, add the plugin to your settings with the catalogs you want to generate
settings.gradle.kts
import dev.aga.gradle.versioncatalogs.Generator.generate
plugins {
id("dev.aga.gradle.version-catalog-generator") version("2.1.1")
}
dependencyResolutionManagement {
repositories {
mavenCentral() // (1)
}
versionCatalogs {
generate("springLibs") { // (2)
from(toml("springBootDependencies")) // (3)
propertyOverrides = mapOf(
"jackson-bom.version" to "2.16.1", // (4)
"mockito.version" to versionRef("mockito"), // (5)
)
generateBomEntry = true // (6)
}
generate("awsLibs") {
from(toml("awsBom"))
aliasPrefixGenerator = GeneratorConfig.NO_PREFIX // (7)
}
}
}
-
Must include repositories here for dependency resolution to work from settings
-
The name of the generated catalog
-
The name of the bom library in the version catalog
-
Optionally override some version properties using a literal value
-
Or, you can reference version aliases in the source TOML
-
Optionally generate an entry in the catalog for the BOM itself
-
All dependencies in the AWS BOM are for AWS so we can skip the prefix
Lastly, use the dependencies in your build
build.gradle.kts
dependencies {
implementation(awsLibs.s3)
implementation(awsLibs.dynamodb)
implementation(springLibs.spring.springBootStarterWeb)
implementation(springLibs.jackson.jacksonDatabind)
}