Skip to content

Commit

Permalink
Update PostgreSQL initialization, Gradle version, and dependencies
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
smyrgeorge committed Jan 12, 2025
1 parent 77c27ea commit 1479def
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Project> {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
override fun apply(project: Project) {
project.plugins.apply("org.jetbrains.kotlin.multiplatform")
project.extensions.configure<KotlinMultiplatformExtension> {
jvm {
compilerOptions {
jvmTarget.set(JVM_17)
}
withJava()
}
applyDefaultHierarchyTemplate()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,6 +19,15 @@ class PublishConventions : Plugin<Project> {
override fun apply(project: Project) {
project.plugins.apply("com.vanniktech.maven.publish")
project.extensions.configure<MavenPublishBaseExtension> {
// 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,
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group = "io.github.smyrgeorge"
version = "0.30.0"
version = "0.40.0"

plugins {
alias(libs.plugins.dokka)
Expand Down
11 changes: 7 additions & 4 deletions examples/postgres-sqldelight/src/commonMain/kotlin/Main.kt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 1 addition & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion sqlx4k-sqldelight-dialect-mysql/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion sqlx4k-sqldelight-dialect-postgres/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion sqlx4k-sqldelight/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit 1479def

Please sign in to comment.