Back to Exposed

exposed-version-catalog

exposed-version-catalog/README.md

1.5.02.2 KB
Original Source

exposed-version-catalog

A Gradle version catalog for all published Exposed modules. It lets you reference Exposed dependencies through type-safe accessors instead of hard-coding coordinates and versions.

Usage

Import the catalog in your settings.gradle.kts:

kotlin
dependencyResolutionManagement {
    repositories {
        mavenCentral()
    }
    versionCatalogs {
        create("exposedLibs") {
            from("org.jetbrains.exposed:exposed-version-catalog:1.5.0")
        }
    }
}

Then reference modules in your build.gradle.kts:

kotlin
dependencies {
    implementation(exposedLibs.core)
    implementation(exposedLibs.jdbc)
    implementation(exposedLibs.kotlin.datetime)
}

The accessor for each module is its module name with the exposed- prefix removed and dashes turned into nested accessors, for example:

ModuleAccessor
exposed-coreexposedLibs.core
exposed-jdbcexposedLibs.jdbc
exposed-r2dbcexposedLibs.r2dbc
exposed-kotlin-datetimeexposedLibs.kotlin.datetime
spring7-transactionexposedLibs.spring7.transaction

All libraries share the exposed version, so you can override the whole Exposed version in one place:

kotlin
versionCatalogs {
    create("exposedLibs") {
        from("org.jetbrains.exposed:exposed-version-catalog:1.5.0")
        version("exposed", "1.5.0")
    }
}

Why exposedLibs and not exposed? The Exposed Gradle plugin registers a project extension named exposed (the exposed { migrations { } } DSL). A version catalog is also exposed as a project extension named after the catalog, so naming this catalog exposed would clash with the plugin (Cannot add extension with name 'exposed'). Naming it exposedLibs keeps both usable in the same project. If you don't apply the Exposed Gradle plugin, you're free to name the catalog exposed.