diff --git a/README.md b/README.md index a53fdcff7d..c8efd86e28 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 - a Gradle version catalog for all Exposed modules ```xml @@ -140,13 +141,13 @@ 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' @@ -164,13 +165,13 @@ 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") @@ -183,6 +184,42 @@ and in `gradle.properties` exposedVersion=1.0.0-beta-2 ``` +#### Using Version Catalog + +Exposed provides a Gradle version catalog that can be used to manage dependencies in a more convenient way. To use it, add the following to your `settings.gradle.kts` file: + +```kotlin +dependencyResolutionManagement { + versionCatalogs { + create("exposed") { + from("org.jetbrains.exposed:exposed-version-catalog:1.0.0-beta-2") + } + } +} +``` + +Then, in your `build.gradle.kts` file, you can reference the dependencies using the version catalog: + +```kotlin +dependencies { + implementation(exposed.core) + implementation(exposed.dao) + implementation(exposed.jdbc) + + // Use one of the date-time extensions + implementation(exposed.jodatime) + // or + implementation(exposed.java.time) + // or + implementation(exposed.kotlin.datetime) + + // Other modules as needed + implementation(exposed.json) + implementation(exposed.money) + implementation(exposed.crypt) +} +``` + ## Samples Check out the [samples](samples/README.md) for a quick start. @@ -310,7 +347,7 @@ fun main() { } println("Manual join:") - + (Users innerJoin Cities) .select(Users.name, Cities.name) .where { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index cedc7d4599..0291195c96 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -20,5 +20,9 @@ gradlePlugin { id = "testWithDBs" implementationClass = "org.jetbrains.exposed.gradle.DBTestingPlugin" } + create("versionCatalog") { + id = "exposed-version-catalog" + implementationClass = "org.jetbrains.exposed.gradle.VersionCatalogPlugin" + } } } diff --git a/buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/DBTestingPlugin.kt b/buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/DBTestingPlugin.kt new file mode 100644 index 0000000000..1f3ac7d714 --- /dev/null +++ b/buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/DBTestingPlugin.kt @@ -0,0 +1,11 @@ +package org.jetbrains.exposed.gradle + +import org.gradle.api.Plugin +import org.gradle.api.Project + +class DBTestingPlugin : Plugin { + override fun apply(project: Project) { + // This plugin is used to configure database testing for the Exposed project + // The actual implementation is in TestDbDsl.kt + } +} diff --git a/buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/VersionCatalog.kt b/buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/VersionCatalog.kt new file mode 100644 index 0000000000..5a175e2b50 --- /dev/null +++ b/buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/VersionCatalog.kt @@ -0,0 +1,90 @@ +package org.jetbrains.exposed.gradle + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.plugins.catalog.CatalogPluginExtension +import org.gradle.api.publish.PublishingExtension +import org.gradle.api.publish.maven.MavenPublication +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.create +import org.gradle.kotlin.dsl.get +import org.gradle.kotlin.dsl.provideDelegate +import org.gradle.kotlin.dsl.register + +class VersionCatalogPlugin : Plugin { + override fun apply(project: Project) { + project.apply(plugin = "version-catalog") + project.apply(plugin = "maven-publish") + project.apply(plugin = "signing") + + project.group = "org.jetbrains.exposed" + + project.configure { + versionCatalog { + val version: String by project.rootProject + + // Core modules + library("core", "org.jetbrains.exposed:exposed-core:$version") + library("dao", "org.jetbrains.exposed:exposed-dao:$version") + library("jdbc", "org.jetbrains.exposed:exposed-jdbc:$version") + + // Extension modules + library("java.time", "org.jetbrains.exposed:exposed-java-time:$version") + library("jodatime", "org.jetbrains.exposed:exposed-jodatime:$version") + library("kotlin.datetime", "org.jetbrains.exposed:exposed-kotlin-datetime:$version") + library("json", "org.jetbrains.exposed:exposed-json:$version") + library("money", "org.jetbrains.exposed:exposed-money:$version") + library("crypt", "org.jetbrains.exposed:exposed-crypt:$version") + library("migration", "org.jetbrains.exposed:exposed-migration:$version") + + // Integration modules + library("spring.boot.starter", "org.jetbrains.exposed:exposed-spring-boot-starter:$version") + library("spring.transaction", "org.jetbrains.exposed:spring-transaction:$version") + + // R2DBC module + library("r2dbc", "org.jetbrains.exposed:exposed-r2dbc:$version") + + // BOM + library("bom", "org.jetbrains.exposed:exposed-bom:$version") + + // Create bundles + bundle("core", listOf("core", "dao", "jdbc")) + bundle("datetime", listOf("java.time", "jodatime", "kotlin.datetime")) + } + } + + project.extensions.configure("publishing") { + val version: String by project.rootProject + + publications { + create("versionCatalog") { + groupId = "org.jetbrains.exposed" + artifactId = project.name + this.version = version + from(project.components["versionCatalog"]) + + pom { + configureMavenCentralMetadata(project) + description by "Exposed, an ORM framework for Kotlin - Version Catalog" + } + signPublicationIfKeyPresent(project) + } + } + + val publishingUsername: String? = System.getenv("PUBLISHING_USERNAME") + val publishingPassword: String? = System.getenv("PUBLISHING_PASSWORD") + + repositories { + maven { + name = "Exposed" + url = project.uri("https://maven.pkg.jetbrains.space/public/p/exposed/release") + credentials { + username = publishingUsername + password = publishingPassword + } + } + } + } + } +} diff --git a/exposed-version-catalog/build.gradle.kts b/exposed-version-catalog/build.gradle.kts new file mode 100644 index 0000000000..a1a21c01fe --- /dev/null +++ b/exposed-version-catalog/build.gradle.kts @@ -0,0 +1,3 @@ +plugins { + id("exposed-version-catalog") +} 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 {