= 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: 2.0.0-beta.2
:icons: font
Easily use any BOM as a https://docs.gradle.org/current/userguide/platforms.html[Gradle Version Catalog].
== Compatibility
[%autowidth]
|===
|Gradle Version|Plugin Version
|7.6.x
|1.x
|8.x
|1.x, 2.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 {
generate("springLibs") { // <2>
from(toml("springBootDependencies")) // <3>
propertyOverrides = mapOf(
"jackson-bom.version" to "2.16.1", // <4>
"mockito.version" to versionRef("mockito"), // <5>
)
}
generate("awsLibs") {
from(toml("awsBom"))
aliasPrefixGenerator = GeneratorConfig.NO_PREFIX // <6>
}
}
}
<1> Must include repositories here for dependency resolution to work from settings
<2> The name of the generated catalog
<3> The name of the bom library in the version catalog
<4> Optionally override some version properties using a literal value
<5> Or, you can reference version aliases in the source TOML
<6> 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
[%collapsible%open]
====
[source,kotlin]
----
dependencies {
implementation(awsLibs.s3)
implementation(awsLibs.dynamodb)
implementation(springLibs.spring.springBootStarterWeb)
implementation(springLibs.jackson.jacksonDatabind)
}
----
====
// tag::exclude-from-docs[]
== 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[]