From 1479defc4a2e7a11ce2bbee0c34ca57b3f7f9802 Mon Sep 17 00:00:00 2001 From: George Smyrnaios Date: Sun, 12 Jan 2025 17:46:46 +0100 Subject: [PATCH] Update PostgreSQL initialization, Gradle version, and dependencies Refactored PostgreSQL options setup to use a Driver Pool with custom max connections and updated project dependencies, including bumping `sqlx4k` to v0.40.0. Upgraded the Gradle wrapper to v8.11.1 and added improved Kotlin Multiplatform publishing conventions. Also fixed plugin ordering issues in the build scripts across multiple modules. --- .../multiplatform/MultiplatformJvmConventions.kt | 6 ------ .../smyrgeorge/sqlx4k/publish/PublishConventions.kt | 11 +++++++++++ build.gradle.kts | 2 +- .../postgres-sqldelight/src/commonMain/kotlin/Main.kt | 11 +++++++---- gradle/libs.versions.toml | 6 +----- gradle/wrapper/gradle-wrapper.properties | 2 +- sqlx4k-sqldelight-dialect-mysql/build.gradle.kts | 2 +- sqlx4k-sqldelight-dialect-postgres/build.gradle.kts | 2 +- sqlx4k-sqldelight/build.gradle.kts | 2 +- 9 files changed, 24 insertions(+), 20 deletions(-) diff --git a/build-logic/plugins/src/main/kotlin/io/github/smyrgeorge/sqlx4k/multiplatform/MultiplatformJvmConventions.kt b/build-logic/plugins/src/main/kotlin/io/github/smyrgeorge/sqlx4k/multiplatform/MultiplatformJvmConventions.kt index 9b90b98..a5a7138 100644 --- a/build-logic/plugins/src/main/kotlin/io/github/smyrgeorge/sqlx4k/multiplatform/MultiplatformJvmConventions.kt +++ b/build-logic/plugins/src/main/kotlin/io/github/smyrgeorge/sqlx4k/multiplatform/MultiplatformJvmConventions.kt @@ -3,19 +3,13 @@ package io.github.smyrgeorge.sqlx4k.multiplatform import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.configure -import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi -import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension class MultiplatformJvmConventions : Plugin { - @OptIn(ExperimentalKotlinGradlePluginApi::class) override fun apply(project: Project) { project.plugins.apply("org.jetbrains.kotlin.multiplatform") project.extensions.configure { jvm { - compilerOptions { - jvmTarget.set(JVM_17) - } withJava() } applyDefaultHierarchyTemplate() diff --git a/build-logic/plugins/src/main/kotlin/io/github/smyrgeorge/sqlx4k/publish/PublishConventions.kt b/build-logic/plugins/src/main/kotlin/io/github/smyrgeorge/sqlx4k/publish/PublishConventions.kt index e512f66..a49d7b7 100644 --- a/build-logic/plugins/src/main/kotlin/io/github/smyrgeorge/sqlx4k/publish/PublishConventions.kt +++ b/build-logic/plugins/src/main/kotlin/io/github/smyrgeorge/sqlx4k/publish/PublishConventions.kt @@ -1,5 +1,7 @@ package io.github.smyrgeorge.sqlx4k.publish +import com.vanniktech.maven.publish.JavadocJar +import com.vanniktech.maven.publish.KotlinMultiplatform import com.vanniktech.maven.publish.MavenPublishBaseExtension import com.vanniktech.maven.publish.SonatypeHost import org.gradle.api.Plugin @@ -17,6 +19,15 @@ class PublishConventions : Plugin { override fun apply(project: Project) { project.plugins.apply("com.vanniktech.maven.publish") project.extensions.configure { + // sources publishing is always enabled by the Kotlin Multiplatform plugin + configure( + KotlinMultiplatform( + // whether to publish a sources jar + sourcesJar = true, + // configures the -javadoc artifact, possible values: + javadocJar = JavadocJar.Dokka("dokkaHtml"), + ) + ) coordinates( groupId = project.group as String, artifactId = project.name, diff --git a/build.gradle.kts b/build.gradle.kts index 716285d..3c59275 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ group = "io.github.smyrgeorge" -version = "0.30.0" +version = "0.40.0" plugins { alias(libs.plugins.dokka) diff --git a/examples/postgres-sqldelight/src/commonMain/kotlin/Main.kt b/examples/postgres-sqldelight/src/commonMain/kotlin/Main.kt index 6890811..e1cbc1e 100644 --- a/examples/postgres-sqldelight/src/commonMain/kotlin/Main.kt +++ b/examples/postgres-sqldelight/src/commonMain/kotlin/Main.kt @@ -1,19 +1,22 @@ import app.cash.sqldelight.async.coroutines.awaitAsList import db.entities.Customer import db.entities.Database +import io.github.smyrgeorge.sqlx4k.Driver import io.github.smyrgeorge.sqlx4k.postgres.PostgreSQL import io.github.smyrgeorge.sqlx4k.sqldelight.Sqlx4kSqldelightDriver import kotlinx.coroutines.runBlocking fun main() { runBlocking { + val options = Driver.Pool.Options.builder() + .maxConnections(20) + .build() + val postgres = PostgreSQL( - host = "localhost", - port = 15432, + url = "postgresql://localhost:15432/test", username = "postgres", password = "postgres", - database = "test", - maxConnections = 10 + options = options ) val sqldelightDriver = Sqlx4kSqldelightDriver(postgres) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3e5c114..1977dad 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,24 +9,20 @@ publish = "0.30.0" sqldelight = "2.0.2" # https://github.com/Kotlin/dokka dokka = "2.0.0" -# https://github.com/willowtreeapps/assertk -assertk = "0.28.1" # https://github.com/touchlab/Stately stately = "2.1.0" # https://github.com/smyrgeorge/sqlx4k -sqlx4k = "0.34.0" +sqlx4k = "0.40.0" [libraries] gradle-kotlin-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } gradle-publish-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "publish" } -kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" } sqldeligh = { module = "app.cash.sqldelight:runtime", version.ref = "sqldelight" } sqldelight-dialect-api = { module = "app.cash.sqldelight:dialect-api", version.ref = "sqldelight" } sqldelight-compiler-env = { module = "app.cash.sqldelight:compiler-env", version.ref = "sqldelight" } sqldelight-mysql-dialect = { module = "app.cash.sqldelight:mysql-dialect", version.ref = "sqldelight" } sqldelight-postgresql-dialect = { module = "app.cash.sqldelight:postgresql-dialect", version.ref = "sqldelight" } -assertk = { module = "com.willowtreeapps.assertk:assertk", version.ref = "assertk" } stately-concurrency = { module = "co.touchlab:stately-concurrency", version.ref = "stately" } sqlx4k = { module = "io.github.smyrgeorge:sqlx4k", version.ref = "sqlx4k" } sqlx4k-postgres = { module = "io.github.smyrgeorge:sqlx4k-postgres", version.ref = "sqlx4k" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 09523c0..e2847c8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/sqlx4k-sqldelight-dialect-mysql/build.gradle.kts b/sqlx4k-sqldelight-dialect-mysql/build.gradle.kts index f9100f5..d7f84d1 100644 --- a/sqlx4k-sqldelight-dialect-mysql/build.gradle.kts +++ b/sqlx4k-sqldelight-dialect-mysql/build.gradle.kts @@ -1,6 +1,6 @@ plugins { - id("io.github.smyrgeorge.sqlx4k.publish") id("io.github.smyrgeorge.sqlx4k.multiplatform.jvm") + id("io.github.smyrgeorge.sqlx4k.publish") } kotlin { diff --git a/sqlx4k-sqldelight-dialect-postgres/build.gradle.kts b/sqlx4k-sqldelight-dialect-postgres/build.gradle.kts index ddbb2e6..ac180ac 100644 --- a/sqlx4k-sqldelight-dialect-postgres/build.gradle.kts +++ b/sqlx4k-sqldelight-dialect-postgres/build.gradle.kts @@ -1,6 +1,6 @@ plugins { - id("io.github.smyrgeorge.sqlx4k.publish") id("io.github.smyrgeorge.sqlx4k.multiplatform.jvm") + id("io.github.smyrgeorge.sqlx4k.publish") } kotlin { diff --git a/sqlx4k-sqldelight/build.gradle.kts b/sqlx4k-sqldelight/build.gradle.kts index b847ea1..00d97b0 100644 --- a/sqlx4k-sqldelight/build.gradle.kts +++ b/sqlx4k-sqldelight/build.gradle.kts @@ -1,6 +1,6 @@ plugins { - id("io.github.smyrgeorge.sqlx4k.publish") id("io.github.smyrgeorge.sqlx4k.multiplatform.simple") + id("io.github.smyrgeorge.sqlx4k.publish") } kotlin {