### Default Alias Generation Examples Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/naming.adoc Illustrates the default prefix and suffix generation logic for library aliases with specific dependency examples. ```text org.springframework.boot:spring-boot-starter-web -> spring-springBootStarterWeb com.fasterxml.jackson.core:jackson-databind -> jackson-jacksonDatabind com.fasterxml.jackson.datatype:jackson-datatype-jsr310 -> jackson-jacksonDatatypeJsr310 software.amazon.awssdk:s3 -> awssdk-s3 org.hibernate.orm:hibernate-core -> orm.hibernateCore ``` -------------------------------- ### Generate Version Catalog from TOML and Maven BOMs (Kotlin DSL) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/sources.adoc Configure a version catalog named 'manyLibs' by including dependencies from specified TOML files and a Maven BOM. This example demonstrates how to use `toml` and direct `from` declarations for BOMs. ```kotlin dependencyResolutionmanagement { versionCatalogs { generate("manyLibs") { using { // excluded for brevity } from { toml { libraryAliases = listOf("spring-boot-dependencies", "aws-bom") } using { // excluded for brevity } } from("org.junit.jupiter:junit-bom:5.11.4") } } } ``` -------------------------------- ### Generate Bundles (Groovy) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/naming.adoc Define bundles from generated libraries in Groovy scripts. This example illustrates how to specify bundle names and conditions. ```groovy generator.generate("myLibs") { it.bundle { dep -> dep.versionRef } // <1> it.bundle("junit") { it.alias.contains("junit") } // <2> it.bundle({ dep -> dep.versionRef }) { dep -> dep.versionRef != null && dep.alias.contains("dropwizard") } // <3> } ``` -------------------------------- ### Generate Bundles (Kotlin) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/naming.adoc Define bundles from generated libraries using the `bundle` function. This example shows different conditions for adding libraries to bundles. ```kotlin generator.generate("myLibs") { bundle { it.versionRef } // <1> bundle("junit") { "junit" in it.alias } // <2> bundle({ it.versionRef }) { it.versionRef != null && it.alias.contains("dropwizard") } // <3> } ``` -------------------------------- ### Generate Version Catalog from TOML and Maven BOMs (Groovy DSL) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/sources.adoc Configure a version catalog named 'manyLibs' using the Groovy DSL. This snippet shows how to include dependencies from TOML files and a Maven BOM, similar to the Kotlin DSL example but with Groovy syntax. ```groovy dependencyResolutionmanagement { versionCatalogs { geneartor.generate("manyLibs") { it.using { // excluded for brevity } it.from { from -> from.toml { toml -> toml.libraryAliases = ["spring-boot-dependencies", "aws-bom"] } from.using { // excluded for brevity } } it.from("org.junit.jupiter:junit-bom:5.11.4") } } } ``` -------------------------------- ### Generated TOML for Versionless Libraries Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/library-versions.adoc Example of the generated TOML catalog when `generateLibraryVersions` is set to `false` for a BOM. Note that the BOM entry itself retains its version reference. ```toml [versions] spring-boot = "3.4.0" # ...other version aliases derived from BOM properties... [libraries] # BOM entry retains its version so platform(...) works spring-springBootDependencies = { group = "org.springframework.boot", name = "spring-boot-dependencies", version.ref = "spring-boot" } ``` -------------------------------- ### Case Conversion (Groovy) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/naming.adoc Convert text cases using the `caseChange` function in Groovy. This example converts from lower-hyphen to camelCase. An import for `CaseFormat` is required. ```groovy using.aliasSuffixGenerator = { _, _, artifactId -> caseChange(artifactId, CaseFormat.LOWER_HYPEN, CaseFormat.CAMEL) // <1> } ``` -------------------------------- ### Customize Version Alias Generation (Groovy) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/naming.adoc Override the `versionNameGenerator` in `GeneratorConfig` for Groovy scripts. This example demonstrates setting a custom generator and using the default logic. ```groovy generator.generate("myLibs") { // excluded for brevity it.using { using -> // <1> using.versionNameGenerator = { propertyName -> // <2> if(propertyName == "somethingWeird") { "notAsWeird" } else { DEFAULT_VERSION_NAME_GENERATOR.invoke(propertyName) // <3> } } } it.from { from -> // excluded for brevity from.using { using -> using.versionNameGenerator = DEFAULT_VERSION_NAME_GENERATOR // <4> } } } ``` -------------------------------- ### Customize Version Alias Generation (Kotlin) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/naming.adoc Override the `versionNameGenerator` in `GeneratorConfig` to customize how version aliases are generated. This example shows how to use the default logic while handling a specific case. ```kotlin generate("myLibs") { // excluded for brevity using { // <1> versionNameGenerator = { propertyName -> // <2> if(propertyName == "somethingWeird") { "notAsWeird" } else { GeneratorConfig.DEFAULT_VERSION_NAME_GENERATOR(propertyName) // <3> } } } from { // excluded for brevity using { versionNameGenerator = GeneratorConfig.DEFAULT_VERSION_NAME_GENERATOR // <4> } } } ``` -------------------------------- ### Customizing Alias Suffix Generation (Groovy DSL) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/naming.adoc Customize suffix generation in Groovy DSL by overriding `aliasSuffixGenerator`. This example demonstrates removing a 'spring' prefix from the generated suffix. ```groovy generator.generate("myLibs") { // excluded for brevity it.using { using -> // <1> using.aliasSuffixGenerator = { prefix, groupId, artifactId -> // <2> def suffix = DEFAULT_ALIAS_SUFFIX_GENERATOR.invoke(groupId, artifactId) // <3> if(prefix == "spring") { suffix.replaceFirst("spring","") // <4> } else { suffix } } } it.from { from.using { aliasSuffixGenerator = DEFAULT_ALIAS_SUFFIX_GENERATOR // <5> } } } ``` -------------------------------- ### Enable and Configure Catalog Saving (Groovy DSL) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/persisting.adoc Enable saving the generated catalog to disk and specify the directory for saving. If not specified, catalogs are saved in `build/version-catalogs` relative to the root project directory. ```groovy generator.generate("myLibs") { // excluded for brevity it.saveGeneratedCatalog = true // <1> it.saveDirectory = file("build/version-catalogs") // <2> } ``` -------------------------------- ### Enable and Configure Catalog Saving (Kotlin DSL) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/persisting.adoc Enable saving the generated catalog to disk and specify the directory for saving. If not specified, catalogs are saved in `build/version-catalogs` relative to the root project directory. ```kotlin generate("myLibs") { // excluded for brevity saveGeneratedCatalog = true // <1> saveDirectory = file("build/version-catalogs") // <2> } ``` -------------------------------- ### Generate Version Catalog from String Notation (Groovy) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/sources.adoc Configures version catalogs using direct dependency string notation in Groovy. 'springLibs' is defined with a Spring Boot dependency, and 'awsLibs' uses an AWS SDK BOM via the `from()` method. ```groovy dependencyResolutionmanagement { versionCatalogs { generator.generate("springLibs") { it.from { from.dependency("org.springframework.boot:spring-boot-dependencies:3.1.2") // <1> } } generator.generate("awsLibs") { it.from("software.amazon.awssdk:bom:2.25.6") // <2> } } } ``` -------------------------------- ### Apply Plugin in settings.gradle.kts Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/applying.adoc Apply the plugin and configure version catalogs in a Kotlin DSL settings script. Ensure the 'generate' function is imported and repositories are declared for dependency resolution. ```kotlin import dev.aga.gradle.versioncatalogs.Generator.generate // <1> plugins { id("dev.aga.gradle.version-catalog-generator") version "{version}" } dependencyResolutionManagement { repositories { // <2> mavenCentral() } versionCatalogs { generate("myLibs") { // excluded for brevity } } } ``` -------------------------------- ### Consuming Versionless Catalog with BOM in Kotlin Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/library-versions.adoc Import the BOM as a platform and use versionless catalog entries. Gradle supplies the version from the platform constraint at resolution time. ```kotlin dependencies { implementation(platform(libs.spring.springBootDependencies)) // <1> implementation(libs.spring.springBootStarterWeb) // <2> implementation(libs.spring.springBootStarterJdbc) // <2> } ``` -------------------------------- ### Configure Plugin in settings.gradle.kts Source: https://github.com/austinarbor/version-catalog-generator/blob/main/README.adoc Configure the Version Catalog Generator plugin in your `settings.gradle.kts` file. This involves applying the plugin and defining how version catalogs should be generated from your BOMs. ```kotlin 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> } } } } ``` -------------------------------- ### Generate Version Catalog from String Notation (Kotlin) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/sources.adoc Configures version catalogs using direct dependency string notation in Kotlin. 'springLibs' is defined using a Spring Boot dependency, and 'awsLibs' uses an AWS SDK BOM. ```kotlin dependencyResolutionmanagement { versionCatalogs { generate("springLibs") { from { dependency("org.springframework.boot:spring-boot-dependencies:3.1.2") // <1> } } generate("awsLibs") { from("software.amazon.awssdk:bom:2.25.6") { // <2> // excluded for brevity // <3> } } } } ``` -------------------------------- ### Generate Version Catalog from TOML File (Kotlin) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/sources.adoc Configures a version catalog named 'springLibs' by reading from a TOML file. The defaultVersionCatalog can be overridden. Library aliases are specified, and the TOML file path is provided. ```kotlin dependencyResolutionmanagement { versionCatalogs { generate("springLibs") { defaultVersionCatalog = file("..") // <1> from { toml { libraryAliases = listOf("springBootDependencies") // <2> file = file("gradle/libs.versions.toml") // <3> } } } generate("awsLibs") { fromToml("awsBom") { // <4> // excluded for brevity // <5> } } generate("junitLibs") { from { toml { libraryAliases = listOf("boms-junit5") file = artifact("io.micronaut.platform:micronaut-platform:4.3.6") // <6> } } } } } ``` -------------------------------- ### Consuming Versionless Catalog with BOM in Groovy Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/library-versions.adoc Import the BOM as a platform and use versionless catalog entries. Gradle supplies the version from the platform constraint at resolution time. ```groovy dependencies { implementation platform(libs.spring.springBootDependencies) // <1> implementation libs.spring.springBootStarterWeb // <2> implementation libs.spring.springBootStarterJdbc // <2> } ``` -------------------------------- ### Apply Plugin in settings.gradle Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/applying.adoc Apply the plugin and configure version catalogs in a Groovy DSL settings script. The 'generator' extension is typically available without an explicit import. ```groovy plugins { id 'dev.aga.gradle.version-catalog-generator' version '{version}' } dependencyResolutionManagement { repositories { // <1> mavenCentral() } versionCatalogs { generator.generate("myLibs") { // <2> // excluded for brevity } } } ``` -------------------------------- ### Define BOM Dependencies in libs.versions.toml Source: https://github.com/austinarbor/version-catalog-generator/blob/main/README.adoc Define your BOM dependencies and their versions in the `libs.versions.toml` file. This serves as the source for generating version catalog entries. ```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" } ``` -------------------------------- ### Generate Version Catalog from TOML File (Groovy) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/sources.adoc Configures a version catalog named 'springLibs' using Groovy syntax. It specifies the defaultVersionCatalog, library aliases, and the TOML file path. Convenience function `fromToml` is shown for 'awsLibs'. ```groovy dependencyResolutionmanagement { versionCatalogs { generator.generate("springLibs") { it.defaultVersionCatalog = file("..") // <1> it.from { from -> from.toml { toml.libraryAliases = ["springBootDependencies"] // <2> toml.file = file("gradle/libs.versions.toml") // <3> } } } generator.generate("awsLibs") { it.fromToml("spring-boot-dependencies") // <4> } generate("junitLibs") { it.from { from -> from.toml { toml.libraryAliases = ["boms-junit5"] toml.file = toml.artifact("io.micronaut.platform:micronaut-platform:4.3.6") // <5> } } } } } ``` -------------------------------- ### Set Default and Override Library Versions (Groovy) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/library-versions.adoc Set a global default for `generateLibraryVersions` and then override it for specific sources using Groovy. This allows for consistent versionless libraries with exceptions for particular BOMs. ```groovy generator.generate("libs") { it.using { u -> // <1> u.generateLibraryVersions = false } it.fromToml("springBootDependencies") // <2> it.from { from -> // <3> from.toml { toml.libraryAliases = ["awsBom"] } from.using { u.generateLibraryVersions = true } } } ``` -------------------------------- ### Append to Existing Catalog in Kotlin DSL Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/existing-catalog.adoc Declare an existing catalog using `from(files(...))` before calling `generate`. This allows appending new entries and creating bundles that combine existing and new dependencies. ```kotlin import dev.aga.gradle.versioncatalogs.Generator.generate plugins { id("dev.aga.gradle.version-catalog-generator") version "{version}" } dependencyResolutionManagement { versionCatalogs { create("libs") { // <1> from(files("gradle/libs.versions.toml")) } generate("libs") { bundle { // <2> // excluded for brevity } } } } ``` -------------------------------- ### Configure Nested BOM Entry Generation (Groovy DSL) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/nested-bom-entry.adoc Set the default value for `generateBomEntryForNestedBoms` to `true` to include entries for BOMs imported by root-level BOMs. Override this value for specific `from` declarations. ```groovy generator.generate("springLibs") { it.generateBomEntryForNestedBoms = true // <1> it.from { from -> from.toml { toml -> toml.libraryAliases = ["springBootDependencies"] } from.using { using -> using.generateBomEntryForNestedBoms = true // <2> } } } ``` -------------------------------- ### Set Default and Override Library Versions (Kotlin) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/library-versions.adoc Set a global default for `generateLibraryVersions` and then override it for specific sources. This allows for consistent versionless libraries with exceptions for particular BOMs. ```kotlin generate("libs") { using { generateLibraryVersions = false // <1> } fromToml("springBootDependencies") // <2> fromToml("awsBom") { generateLibraryVersions = true // <3> } } ``` -------------------------------- ### Customizing Alias Prefix Generation Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/naming.adoc Demonstrates how to override the default `aliasPrefixGenerator` in `GeneratorConfig` to provide custom prefix logic for library aliases. ```kotlin generate("myLibs") { // excluded for brevity using { // <1> aliasPrefixGenerator = { groupId, artifactId -> if(groupId == "some.group") { "somegroup" } } } } ``` -------------------------------- ### Append to Existing Catalog in Groovy DSL Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/existing-catalog.adoc Explicitly create the catalog with `libs { from(files(...)) }` before invoking `generator.generate("myLibs")`. This ensures that new bundles can incorporate dependencies from both the original catalog and the generated BOMs. ```groovy plugins { id 'dev.aga.gradle.version-catalog-generator' version '{version}' } dependencyResolutionManagement { versionCatalogs { libs { // <1> from(files("gradle/libs.versions.toml")) } generator.generate("myLibs") { // <2> it.bundle { // excluded for brevity } } } } ``` -------------------------------- ### Configure Nested BOM Entry Generation (Kotlin DSL) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/nested-bom-entry.adoc Set the default value for `generateBomEntryForNestedBoms` to `true` to include entries for BOMs imported by root-level BOMs. Override this value for specific `from` declarations. ```kotlin generate("springLibs") { using { generateBomEntryForNestedBoms = true // <1> } fromToml("springBootDependencies") { generateBomEntryForNestedBoms = false // <2> } } ``` -------------------------------- ### Use Generated Dependencies in build.gradle.kts Source: https://github.com/austinarbor/version-catalog-generator/blob/main/README.adoc Consume the generated version catalog dependencies in your `build.gradle.kts` file. This demonstrates how to reference the aliases created by the plugin. ```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) } ``` -------------------------------- ### Add Additional Dependencies in Groovy DSL Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/additional-dependencies.adoc Configure additional dependencies using `withDepsFromToml`, `withDep`, or `withDeps` in the `generate` block for Groovy DSL. Ensure that `withDepsFromToml` references an existing alias within a loaded catalog. ```groovy plugins { id 'dev.aga.gradle.version-catalog-generator' version '{version}' } dependencyResolutionManagement { versionCatalogs { generator.generate("testingLibs") { it.from { from.toml { toml.libraryAliases = ["junit-bom", "mockito-bom", "assertj-bom"] } from.using { using.withDepsFromToml("mockito-kotlin") // <1> using.withDep("org.mockito.kotlin", "mockito-kotlin", "6.1.0") // <2> using.withDeps("org.mockito.kotlin:mockito-kotlin:6.1.0") // <3> } } } } } ``` -------------------------------- ### Configure BOM Entry Generation in Kotlin DSL Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/bom-entry.adoc Set the default value of `generateBomEntry` to `true` to include an entry for the BOM in the generated catalog. Alternatively, override the value for a specific `from` declaration. ```kotlin generate("springLibs") { using { generateBomEntry = true // <1> } fromToml("springBootDependencies") { generateBomEntry = false // <2> } } ``` -------------------------------- ### Configure BOM Entry Generation in Groovy DSL Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/bom-entry.adoc Set the default value of `generateBomEntry` to `true` to include an entry for the BOM in the generated catalog. Alternatively, override the value for a specific `from` declaration. ```groovy generator.generate("springLibs") { it.generateBomEntry = true // <1> it.from { from -> from.toml { toml -> toml.libraryAliases = ["springBootDependencies"] } from.using { using -> using.generateBomEntry = true // <2> } } } ``` -------------------------------- ### Add Additional Dependencies in Kotlin DSL Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/additional-dependencies.adoc Use `withDepsFromToml`, `withDep`, or `withDeps` within the `generate` block to include dependencies not found in the BOMs. `withDepsFromToml` requires the alias to exist in a loaded catalog. ```kotlin import dev.aga.gradle.versioncatalogs.Generator.generate plugins { id("dev.aga.gradle.version-catalog-generator") version "{version}" } dependencyResolutionManagement { versionCatalogs { generate("testingLibs") { fromToml("junit-bom", "mockito-bom", "assertj-bom") { withDepsFromToml("mockito-kotlin") // <1> withDep("org.mockito.kotlin", "mockito-kotlin", "6.1.0") // <2> withDeps("org.mockito.kotlin:mockito-kotlin:6.1.0") // <3> } } } } ``` -------------------------------- ### Using Generated Libraries in settings.gradle.kts Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/build.adoc When referencing libraries from your generated catalog in Kotlin DSL, hyphens in the alias are replaced with dots. Ensure the catalog is evaluated by another Gradle task to trigger generation. ```kotlin dependencies { implementation(springLibs.spring.springBootStarterWeb) // <1> } <1> When using the libraries from your generated catalog, each `-` in the generated alias is replaced with a `.` ``` -------------------------------- ### Generate Bundles in Groovy DSL Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/migration-4.x.adoc Use this snippet to generate bundles in Groovy DSL for version catalog generation. Ensure your project is configured with the necessary Gradle plugins. ```groovy generator.generate("myLibs") { // excluded for brevity it.bundle { dep -> dep.versionRef } } ``` -------------------------------- ### Generate Bundles in Kotlin DSL Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/migration-4.x.adoc Use this snippet to generate bundles in Kotlin DSL for version catalog generation. Ensure your project is configured with the necessary Gradle plugins. ```kotlin generate("myLibs") { // excluded for brevity bundle { it.versionRef } } ``` -------------------------------- ### Using Generated Libraries in settings.gradle Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/build.adoc When referencing libraries from your generated catalog in Groovy DSL, hyphens in the alias are replaced with dots. Ensure the catalog is evaluated by another Gradle task to trigger generation. ```groovy dependencies { implementation springLibs.spring.springBootStarterWeb // <1> } <1> When using the libraries from your generated catalog, each `-` in the generated alias is replaced with a `.` ``` -------------------------------- ### Override Versions in settings.gradle.kts Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/overrides.adoc Configure default and specific overrides for version properties within the `generate` block. Use string versions or references to existing aliases. The `using` block within `from` allows for localized overrides. ```kotlin generate("myLibs") { // excluded for brevity using { // <1> propertyOverrides = mapOf( "jackson.version" to "2.16.1", // <2> "aws.version" to versionRef("aws") // <3> ) } val someFile = file("/path/to/libs.versions.toml") from { toml { libraryAliases = listOf("some-bom") file = someFile } using { // <4> propertyOverrides = mapOf( "jackson.version" to versionRef("jackson") // <5> ) } } from { // excluded for brevity using { propertyOverrides = mapOf( "jackson.version" to someFile.versionRef("jackson"), // <6> "aws.version" to defaultVersionCatalog.versionRef("aws") // <7> ) } } } ``` -------------------------------- ### Customizing Alias Prefix Generation (Kotlin DSL) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/naming.adoc Set a custom alias prefix generator for all 'from' blocks or override it for specific 'from' blocks. The default logic can be used as a fallback. ```kotlin generate("myLibs") { // excluded for brevity using { aliasPrefixGenerator = { groupId, artifactId -> if(groupId == "some.group") { "somegroup" } else { GeneratorConfig.DEFAULT_ALIAS_PREFIX_GENERATOR.invoke(groupId, artifactId) // <2> } } } from { // excluded for brevity using { aliasPrefixGenerator = GeneratorConfig.DEFAULT_ALIAS_PREFIX_GENERATOR // <3> } } } ``` -------------------------------- ### Customizing Alias Prefix Generation (Groovy DSL) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/naming.adoc Configure a custom alias prefix generator using Groovy DSL. This allows for conditional prefix generation or falling back to the default logic. ```groovy generator.generate("myLibs") { // excluded for brevity it.using { using -> // <1> using.aliasPrefixGenerator = { groupId, artifactId -> if(groupId == "some.group") { "somegroup" } else { DEFAULT_ALIAS_PREFIX_GENERATOR.invoke(groupId, artifactId) // <2> } } } it.from { from -> // excluded for brevity from.using { using -> using.aliasPrefixGenerator = DEFAULT_ALIAS_PREFIX_GENERATOR // <3> } } } ``` -------------------------------- ### Skipping Prefix Generation Entirely (Kotlin DSL) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/naming.adoc Use `GeneratorConfig.NO_PREFIX` to completely skip alias prefix generation for dependencies within a specific 'from' block. This simplifies accessors. ```kotlin generate("awsLibs") { fromToml("awsBom") { aliasPrefixGenerator = GeneratorConfig.NO_PREFIX // <1> } } ``` -------------------------------- ### Skipping Prefix Generation Entirely (Groovy DSL) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/naming.adoc Configure `NO_PREFIX` in Groovy DSL to disable alias prefix generation for dependencies. This results in simpler library accessors. ```groovy generator.generate("awsLibs") { it.fromToml("awsBom") it.using { using -> using.aliasPrefixGenerator = NO_PREFIX // <1> } } ``` -------------------------------- ### Case Conversion (Kotlin) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/naming.adoc Use the `caseChange` function to convert between different text cases, such as lower-hyphen to camelCase. Ensure `CaseFormat` is imported. ```kotlin aliasSuffixGenerator = { _, _, artifactId -> GeneratorConfig.caseChange(artifactId, CaseFormat.LOWER_HYPEN, CaseFormat.CAMEL) // <1> } ``` -------------------------------- ### Customizable Filtering with Kotlin DSL Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/filtering.adoc Use a custom filter lambda to include only dependencies whose artifactId contains 'testing'. This filter can be set globally or per 'from' block. ```kotlin generate("testLibs") { // excluded for brevity using { // <1> filter = { "testing" in it.artifactId } // <2> } from { // excluded for brevity using { // <3> filter = "..." // excluded for brevity } } } ``` -------------------------------- ### Customizable Filtering with Groovy DSL Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/filtering.adoc Use a custom filter lambda to include only dependencies whose artifactId contains 'testing'. This filter can be set globally or per 'from' block. ```groovy generator.generate("testLibs") { // excluded for brevity it.using { using -> // <1> using.filter = { dep -> dep.artifactId.contains("testing") } // <2> } it.from { from -> // excluded for brevity from.using { using -> // <3> using.filter = { "..." } // excluded for brevity } } } ``` -------------------------------- ### Disable Library Versions for a Specific BOM (Kotlin) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/library-versions.adoc Configure a specific BOM to generate library entries without versions. This ensures that the consumer's `platform(...)` import provides the versions at resolution time. ```kotlin generate("libs") { from("org.springframework.boot:spring-boot-dependencies:3.4.0") { generateBomEntry = true // <1> generateLibraryVersions = false // <2> } } ``` -------------------------------- ### Disable Library Versions for a Specific BOM (Groovy) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/library-versions.adoc Configure a specific BOM to generate library entries without versions using Groovy. This ensures that the consumer's `platform(...)` import provides the versions at resolution time. ```groovy generator.generate("libs") { it.from { from -> from.dependency("org.springframework.boot:spring-boot-dependencies:3.4.0") from.using { using -> using.generateBomEntry = true // <1> using.generateLibraryVersions = false // <2> } } } ``` -------------------------------- ### Customizing Alias Suffix Generation (Kotlin DSL) Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/naming.adoc Modify the alias suffix generation logic by providing a custom lambda to `aliasSuffixGenerator`. This allows for conditional modifications to the default suffix. ```kotlin generate("myLibs") { // excluded for brevity using { // <1> aliasSuffixGenerator = { prefix, groupId, artifactId -> // <2> val suffix = GeneratorConfig.DEFAULT_ALIAS_SUFFIX_GENERATOR(groupId, artifactId) // <3> if(prefix == "spring") { suffix.replaceFirst("spring","") // <4> } else { suffix } } } from { // excluded for brevity using { aliasSuffixGenerator = GeneratorConfig.DEFAULT_ALIAS_SUFFIX_GENERATOR // <5> } } } ``` -------------------------------- ### Override Versions in settings.gradle Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/overrides.adoc Configure default and specific overrides for version properties in Groovy DSL. Similar to Kotlin, you can set global overrides and then override them within specific `from` blocks. ```groovy generator.generate("myLibs") { // excluded for brevity it.using { using -> // <1> using.propertyOverrides = [ "jackson.version": "2.16.1", // <2> "aws.version": it.versionRef("aws") // <3> ] } it.from { from.toml { toml.libraryAliases = listOf("some-bom") toml.file = file("/path/to/libs.versions.toml") } from.using { using.propertyOverrides = [ "jackson.version": using.versionRef("jackson") // <5> ] } } } ``` -------------------------------- ### Filtering by GroupId with Kotlin DSL Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/filtering.adoc Exclude dependencies with 'spring' in their groupId using a regular expression. This can be set globally or per 'from' block. ```kotlin generate("myLibs") { // excluded for brevity using { // <1> excludeGroups = ".*spring.*" // <2> } from { // excluded for brevity using { // <3> excludeGroups = "..." // excluded for brevity } } } ``` -------------------------------- ### Filtering by GroupId with Groovy DSL Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/filtering.adoc Exclude dependencies with 'spring' in their groupId using a regular expression. This can be set globally or per 'from' block. ```groovy generator.generate("myLibs") { // excluded for brevity it.using { using -> // <1> using.excludeGroups = ".*spring.*" // <2> } it.from { from -> // excluded for brevity from.using { using -> // <3> using.excludeGroups = "..." // excluded for brevity } } } ``` -------------------------------- ### Filtering by Name (ArtifactId) with Groovy DSL Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/filtering.adoc Exclude dependencies with 'hibernate' in their artifactId using a regular expression. This can be set globally or per 'from' block. ```groovy generator.generate("myLibs") { // excluded for brevity it.using { using -> // <1> using.excludeNames = ".*hibernate.*" // <2> } it.from { // excluded for brevity from.using { using -> // <3> using.excludeNames = "..." } } } ``` -------------------------------- ### Filtering by Name (ArtifactId) with Kotlin DSL Source: https://github.com/austinarbor/version-catalog-generator/blob/main/plugin/src/docs/asciidoc/detailed-usage/filtering.adoc Exclude dependencies with 'hibernate' in their artifactId using a regular expression. This can be set globally or per 'from' block. ```kotlin generate("myLibs") { // excluded for brevity using { // <1> excludeNames = ".*hibernate.*" // <2> } from { // excluded for brevity using { // <3> excludeNames = "..." // excluded for brevity } } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.