https://github.com/austinarbor/version-catalog-generator
Gradle settings plugin to use any BOM as a fully typed version catalog
https://github.com/austinarbor/version-catalog-generator
bom gradle plugin settings version-catalog
Last synced: 3 months ago
JSON representation
Gradle settings plugin to use any BOM as a fully typed version catalog
- Host: GitHub
- URL: https://github.com/austinarbor/version-catalog-generator
- Owner: austinarbor
- License: apache-2.0
- Created: 2023-08-17T03:30:04.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2026-02-26T05:11:49.000Z (4 months ago)
- Last Synced: 2026-02-26T09:38:59.814Z (4 months ago)
- Topics: bom, gradle, plugin, settings, version-catalog
- Language: Kotlin
- Homepage: https://austinarbor.github.io/version-catalog-generator/
- Size: 1.59 MB
- Stars: 44
- Watchers: 3
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
= Version Catalog Generator Plugin
https://github.com/austinarbor/version-catalog-generator/actions/workflows/ci.yml[image:https://github.com/austinarbor/version-catalog-generator/actions/workflows/ci.yml/badge.svg[ci]] https://codecov.io/gh/austinarbor/version-catalog-generator[image:https://codecov.io/gh/austinarbor/version-catalog-generator/graph/badge.svg?token=IO5UCDD5A0[codecov]] https://plugins.gradle.org/plugin/dev.aga.gradle.version-catalog-generator[image:https://staging.shields.io/gradle-plugin-portal/v/dev.aga.gradle.version-catalog-generator?label=Gradle%20Plugin%20Portal[Gradle Plugin Portal]]
:version: 4.0.0
:icons: font
Easily use any BOM as a https://docs.gradle.org/current/userguide/platforms.html[Gradle Version Catalog].
== Compatibility
[%autowidth]
|===
|*Plugin Version*|*Gradle Version*
|1.x
|7.6.x
|1.x, 2.x, 3.x
|8.x
|3.x
|9.x
|4.x
|9.x
|===
== Quick Start
_First, add your BOM dependencies to your version catalog_
.libs.versions.toml
[%collapsible%open]
====
[source,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
[%collapsible%open]
====
[source,kotlin,subs="attributes+"]
----
import dev.aga.gradle.versioncatalogs.Generator.generate
plugins {
id("dev.aga.gradle.version-catalog-generator") version("{version}")
}
dependencyResolutionManagement {
repositories {
mavenCentral() // <1>
}
versionCatalogs {
create("libs") { // <2>
from(files("gradle/libs.versions.toml"))
}
generate("libs") { // <3>
fromToml("springBootDependencies") { // <4>
propertyOverrides = mapOf(
"jackson-bom.version" to "2.16.1", // <5>
"mockito.version" to versionRef("mockito"), // <6>
)
generateBomEntry = true // <7>
}
}
generate("awsLibs") {
fromToml("awsBom") {
aliasPrefixGenerator = GeneratorConfig.NO_PREFIX // <8>
}
}
generate("manyLibs") {
using { // <9>
aliasPrefixGenerator = GeneratorConfig.NO_PREFIX
}
fromToml("aws-bom", "jackson-bom") { // <10>
aliasSuffixGenerator = { prefix, groupId, artifactId -> // <11>
val trimmed = artifactId.replaceFirst("junit-", "").replaceFirst("jackson-", "")
GeneratorConfig.DEFAULT_ALIAS_SUFFIX_GENERATOR(prefix, groupId, trimmed)
}
}
from("org.springframework.boot:spring-boot-dependencies:3.4.1") { // <12>
aliasPrefixGenerator = GeneratorConfig.DEFAULT_ALIAS_PREFIX_GENERATOR // <13>
}
}
}
}
----
<1> Must include repositories here for dependency resolution to work from settings
<2> If you want to append to an existing catalog, you must declare it before using it in a generate block (even if it's the default `libs.versions.toml`)
<3> The name of the generated catalog. If a catalog with that name already exists, the entries will be appended to it. Otherwise, a new catalog will be created.
<4> The name of the bom library in the version catalog
<5> Optionally override some version properties using a literal value
<6> Or, you can reference version aliases in the source TOML
<7> Optionally generate an entry in the catalog for the BOM itself
<8> All dependencies in the AWS BOM are for AWS so we can skip the prefix
<9> Set the default generation options that will apply to all sources unless overridden
<10> Include all dependencies from both `aws-bom` and `jackson-bom`
<11> Override the default `aliasSuffixGenerator` for dependencies in these two BOMs
<12> Also include all dependencies from the `spring-boot-dependencies` BOM in the generated catalog
<13> Override the default `aliasPrefixGenerator` for dependencies in the spring BOM
====
_Lastly, use the dependencies in your build_
.build.gradle.kts
[%collapsible%open]
====
[source,kotlin]
----
dependencies {
implementation(awsLibs.s3)
implementation(awsLibs.dynamodb)
implementation(libs.spring.springBootStarterWeb)
implementation(libs.jackson.jacksonDatabind)
implementation(manyLibs.sts)
implementation(manyLibs.databind)
implementation(manyLibs.spring.springBootStarterJdbc)
}
----
====
// tag::exclude-from-docs[]
== Migrate to 4.x
https://austinarbor.github.io/version-catalog-generator#_migrating_from_3_x_to_4_x[See guide]
== Detailed Usage
https://austinarbor.github.io/version-catalog-generator[See the docs]
== Goals
* [x] Compatible with Dependabot
* [x] Nested BOM support (i.e. `spring-boot-dependences` imports `+mockito-bom+`, etc)
* [x] Easy to override versions (similar to `ext["version.property"] = ...` in Spring Boot Dependencies plugin)
// end::exclude-from-docs[]