diff --git a/README.md b/README.md index a53fdcff7d..9d57e7980c 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ The Maven Central repository is enabled by default for Maven users. * exposed-money - extensions to support MonetaryAmount from "javax.money:money-api" * exposed-spring-boot-starter - a starter for [Spring Boot](https://spring.io/projects/spring-boot) to utilize Exposed as the ORM instead of [Hibernate](https://hibernate.org/) +* exposed-version-catalog - provides a [Gradle Version Catalog](https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog) for Exposed modules ```xml @@ -128,6 +129,11 @@ The Maven Central repository is enabled by default for Maven users. exposed-spring-boot-starter 1.0.0-beta-2 + + org.jetbrains.exposed + exposed-version-catalog + 1.0.0-beta-2 + ``` @@ -140,16 +146,17 @@ dependencies { implementation 'org.jetbrains.exposed:exposed-crypt:1.0.0-beta-2' implementation 'org.jetbrains.exposed:exposed-dao:1.0.0-beta-2' implementation 'org.jetbrains.exposed:exposed-jdbc:1.0.0-beta-2' - + implementation 'org.jetbrains.exposed:exposed-jodatime:1.0.0-beta-2' // or implementation 'org.jetbrains.exposed:exposed-java-time:1.0.0-beta-2' // or implementation 'org.jetbrains.exposed:exposed-kotlin-datetime:1.0.0-beta-2' - + implementation 'org.jetbrains.exposed:exposed-json:1.0.0-beta-2' implementation 'org.jetbrains.exposed:exposed-money:1.0.0-beta-2' implementation 'org.jetbrains.exposed:exposed-spring-boot-starter:1.0.0-beta-2' + implementation 'org.jetbrains.exposed:exposed-version-catalog:1.0.0-beta-2' } ``` @@ -164,16 +171,17 @@ dependencies { implementation("org.jetbrains.exposed:exposed-crypt:$exposedVersion") implementation("org.jetbrains.exposed:exposed-dao:$exposedVersion") implementation("org.jetbrains.exposed:exposed-jdbc:$exposedVersion") - + implementation("org.jetbrains.exposed:exposed-jodatime:$exposedVersion") // or implementation("org.jetbrains.exposed:exposed-java-time:$exposedVersion") // or implementation("org.jetbrains.exposed:exposed-kotlin-datetime:$exposedVersion") - + implementation("org.jetbrains.exposed:exposed-json:$exposedVersion") implementation("org.jetbrains.exposed:exposed-money:$exposedVersion") implementation("org.jetbrains.exposed:exposed-spring-boot-starter:$exposedVersion") + implementation("org.jetbrains.exposed:exposed-version-catalog:$exposedVersion") } ``` @@ -183,6 +191,39 @@ and in `gradle.properties` exposedVersion=1.0.0-beta-2 ``` +#### Using Version Catalog + +Alternatively, you can use the Exposed Version Catalog to manage dependencies: + +In `settings.gradle.kts`: + +```kotlin +dependencyResolutionManagement { + versionCatalogs { + create("exposed") { + from("org.jetbrains.exposed:exposed-version-catalog:1.0.0-beta-2") + } + } +} +``` + +In `build.gradle.kts`: + +```kotlin +dependencies { + implementation(exposed.core) + implementation(exposed.dao) + implementation(exposed.jdbc) + + // For modules with hyphens in their names, use dot notation + implementation(exposed.kotlin.datetime) + implementation(exposed.java.time) + implementation(exposed.spring.boot.starter) +} +``` + +This approach provides type-safe accessors for all Exposed modules and ensures version consistency. + ## Samples Check out the [samples](samples/README.md) for a quick start. @@ -310,7 +351,7 @@ fun main() { } println("Manual join:") - + (Users innerJoin Cities) .select(Users.name, Cities.name) .where { diff --git a/build.gradle.kts b/build.gradle.kts index 0018f69395..26982a6fd6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -38,13 +38,13 @@ repositories { } allprojects { - if (this.name != "exposed-tests" && this.name != "exposed-bom" && this.name != "exposed-r2dbc-tests" && this != rootProject) { + if (this.name != "exposed-tests" && this.name != "exposed-bom" && this.name != "exposed-r2dbc-tests" && this.name != "exposed-version-catalog" && this != rootProject) { configurePublishing() } } apiValidation { - ignoredProjects.addAll(listOf("exposed-tests", "exposed-bom", "exposed-r2dbc-tests")) + ignoredProjects.addAll(listOf("exposed-tests", "exposed-bom", "exposed-r2dbc-tests", "exposed-version-catalog")) } subprojects { diff --git a/exposed-version-catalog/README.md b/exposed-version-catalog/README.md new file mode 100644 index 0000000000..2d4c11e9a6 --- /dev/null +++ b/exposed-version-catalog/README.md @@ -0,0 +1,65 @@ +# Exposed Version Catalog + +This module provides a [Gradle Version Catalog](https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog) for Exposed modules. + +## Usage + +### In settings.gradle.kts + +Add the following to your `settings.gradle.kts` file: + +```kotlin +dependencyResolutionManagement { + versionCatalogs { + create("exposed") { + from("org.jetbrains.exposed:exposed-version-catalog:") + } + } +} +``` + +Replace `` with the version of Exposed you want to use. + +### In build.gradle.kts + +You can then use the version catalog in your `build.gradle.kts` file: + +```kotlin +dependencies { + implementation(exposed.core) + implementation(exposed.dao) + implementation(exposed.jdbc) + + // For modules with hyphens in their names, use dot notation + implementation(exposed.kotlin.datetime) + implementation(exposed.java.time) + implementation(exposed.spring.boot.starter) +} +``` + +## Available Dependencies + +The version catalog includes all Exposed modules: + +- `exposed.core` - Core module with SQL DSL +- `exposed.dao` - DAO API implementation +- `exposed.jdbc` - JDBC transport implementation +- `exposed.kotlin.datetime` - Kotlin DateTime extensions +- `exposed.java.time` - Java Time extensions +- `exposed.jodatime` - JodaTime extensions +- `exposed.json` - JSON data type extensions +- `exposed.money` - MonetaryAmount extensions +- `exposed.crypt` - Encrypted data type extensions +- `exposed.migration` - Database migration support +- `exposed.r2dbc` - R2DBC reactive implementation +- `exposed.spring.boot.starter` - Spring Boot integration +- `spring.transaction` - Spring transaction support + +## Benefits + +Using the version catalog provides several benefits: + +1. **Type-safe accessors** - You get type-safe accessors for all Exposed modules +2. **Version consistency** - All modules use the same version +3. **Simplified dependency management** - No need to specify group and version for each dependency +4. **IDE support** - Better IDE support with code completion diff --git a/exposed-version-catalog/build.gradle.kts b/exposed-version-catalog/build.gradle.kts new file mode 100644 index 0000000000..ecc13e13b6 --- /dev/null +++ b/exposed-version-catalog/build.gradle.kts @@ -0,0 +1,98 @@ +plugins { + `version-catalog` + `maven-publish` + signing +} + +group = "org.jetbrains.exposed" + +catalog { + versionCatalog { + create("exposed") { + rootProject.subprojects.filter { + it.name != "exposed-version-catalog" && + it.name != "exposed-tests" && + it.name != "exposed-r2dbc-tests" && + it.name != "exposed-bom" + }.forEach { project -> + val moduleName = project.name.removePrefix("exposed-") + val nameParts = moduleName.split("-") + val accessorName = if (nameParts.size > 1) { + nameParts.joinToString(".") { it } + } else { + moduleName + } + + val version: String by rootProject + val artifactId = project.name + library(accessorName, "org.jetbrains.exposed:$artifactId:$version") + } + } + } +} + +publishing { + val version: String by rootProject + + publications { + create("versionCatalog") { + groupId = "org.jetbrains.exposed" + artifactId = project.name + this.version = version + from(components["versionCatalog"]) + + pom { + name.set("Exposed Version Catalog") + description.set("Version Catalog for Exposed modules") + url.set("https://github.com/JetBrains/Exposed") + + licenses { + license { + name.set("The Apache Software License, Version 2.0") + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") + distribution.set("repo") + } + } + + developers { + developer { + id.set("JetBrains") + name.set("JetBrains Team") + organization.set("JetBrains") + organizationUrl.set("https://www.jetbrains.com") + } + } + + scm { + url.set("https://github.com/JetBrains/Exposed") + connection.set("scm:git:git://github.com/JetBrains/Exposed.git") + } + } + } + } + + val publishingUsername: String? = System.getenv("PUBLISHING_USERNAME") + val publishingPassword: String? = System.getenv("PUBLISHING_PASSWORD") + + repositories { + maven { + name = "Exposed" + url = uri("https://maven.pkg.jetbrains.space/public/p/exposed/release") + credentials { + username = publishingUsername + password = publishingPassword + } + } + } +} + +// Sign publications if signing key is present +val signingKey: String? = System.getenv("SIGN_KEY_PRIVATE") +val signingKeyPassphrase: String? = System.getenv("SIGN_KEY_PASSPHRASE") + +if (signingKey != null && signingKeyPassphrase != null) { + signing { + useInMemoryPgpKeys(signingKey, signingKeyPassphrase) + sign(publishing.publications["versionCatalog"]) + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index e36e181bc8..caad71ab32 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,6 +17,7 @@ include("exposed-json") include("exposed-migration") include("exposed-r2dbc") include("exposed-r2dbc-tests") +include("exposed-version-catalog") pluginManagement { repositories {