From f41860c7d734babd7fde00c8d3c9f088ec3c4f8c Mon Sep 17 00:00:00 2001 From: qiaoyuang Date: Thu, 2 Nov 2023 15:49:34 +0800 Subject: [PATCH 1/2] Update to Kotlin 1.9.20 --- CHANGELOG.md | 13 +- gradle.properties | 5 +- sample/build.gradle.kts | 33 +---- sqllin-driver/build.gradle.kts | 125 +----------------- .../src/nativeInterop/cinterop/sqlite3.def | 2 + .../sqllin/driver/cinterop/SQLiteErrorType.kt | 3 + sqllin-dsl/build.gradle.kts | 114 +--------------- .../kotlin/com/ctrip/sqllin/dsl/DBEntity.kt | 30 ----- 8 files changed, 36 insertions(+), 289 deletions(-) delete mode 100644 sqllin-dsl/src/commonMain/kotlin/com/ctrip/sqllin/dsl/DBEntity.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 896718e..394b185 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,19 @@ ## v1.2.2 / 2023-xx-xx +### All + +* Update `Kotlin`'s version to `1.9.20` + ### sqllin-dsl -* Add the new API `Database#suspendedScope`, it could be used to ensure concurrency safety +* Add the new API `Database#suspendedScope`, it could be used to ensure concurrency safety([#55](https://github.com/ctripcorp/SQLlin/pull/55)) * Begin with this version, _sqllin-dsl_ depends on _kotlinx.coroutines_ version `1.7.3` +* ***Breaking change***: Remove the public class `DBEntity`, we have deprecated it in version `1.1.1` + +### sqllin-processor + +* Update `KSP`'s version to `1.9.20-1.0.13` ## v1.2.1 / 2023-10-18 @@ -37,7 +46,7 @@ a runtime exception. Thanks for [@nbransby](https://github.com/nbransby) ### sqllin-driver * Add the new JVM target -* Breaking change: Remove the public property: `DatabaseConnection#closed` +* ***Breaking change***: Remove the public property: `DatabaseConnection#closed` * The Android (<= 9) target supports to set the `journalMode` and `synchronousMode` now ## v1.1.1 / 2023-08-12 diff --git a/gradle.properties b/gradle.properties index 27cda02..b192388 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ VERSION=1.2.1 GROUP=com.ctrip.kotlin -kotlinVersion=1.9.10 -kspVersion=1.9.10-1.0.13 +kotlinVersion=1.9.20 +kspVersion=1.9.20-1.0.13 coroutinesVersion=1.7.3 #Maven Publish Information @@ -31,4 +31,5 @@ android.disableAutomaticComponentCreation=true kotlin.code.style=official kotlin.mpp.stability.nowarn=true kotlin.mpp.enableCInteropCommonization=true +kotlin.natvie.increment=true #kotlin.compiler.execution.strategy=out-of-process diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts index 91dcc1e..4f52bd6 100644 --- a/sample/build.gradle.kts +++ b/sample/build.gradle.kts @@ -1,5 +1,4 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinCompile -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget plugins { kotlin("multiplatform") @@ -21,15 +20,9 @@ kotlin { } } } - iosX64 { - setupIOSConfig() - } - iosArm64 { - setupIOSConfig() - } - iosSimulatorArm64 { - setupIOSConfig() - } + iosX64() + iosArm64() + iosSimulatorArm64() sourceSets { all { @@ -44,17 +37,6 @@ kotlin { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") } } - val androidMain by getting - val jvmMain by getting - val iosX64Main by getting - val iosArm64Main by getting - val iosSimulatorArm64Main by getting - val iosMain by creating { - dependsOn(commonMain) - iosX64Main.dependsOn(this) - iosArm64Main.dependsOn(this) - iosSimulatorArm64Main.dependsOn(this) - } } } @@ -70,11 +52,6 @@ android { } } -fun KotlinNativeTarget.setupIOSConfig() { - val compileArgs = listOf("-Xallocator=mimalloc", "-Xruntime-logs=gc=info") - compilations["main"].kotlinOptions.freeCompilerArgs += compileArgs -} - dependencies { add("kspCommonMainMetadata", project(":sqllin-processor")) } @@ -86,4 +63,8 @@ afterEvaluate { // WORKAROUND: both register() and named() fail – https://git dependsOn("kspCommonMainKotlinMetadata") } } +} + +tasks.withType { + compilerOptions.freeCompilerArgs.add("-Xexpect-actual-classes") } \ No newline at end of file diff --git a/sqllin-driver/build.gradle.kts b/sqllin-driver/build.gradle.kts index a3f5e00..7df2c2a 100644 --- a/sqllin-driver/build.gradle.kts +++ b/sqllin-driver/build.gradle.kts @@ -1,4 +1,5 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.konan.target.HostManager plugins { @@ -59,7 +60,6 @@ kotlin { optIn("kotlin.RequiresOptIn") } } - val commonMain by getting val commonTest by getting { dependencies { implementation(kotlin("test")) @@ -73,7 +73,6 @@ kotlin { } } val androidInstrumentedTest by getting { - dependsOn(commonTest) dependencies { implementation("androidx.test:core:1.5.0") implementation("androidx.test:runner:1.5.2") @@ -86,124 +85,6 @@ kotlin { implementation("org.xerial:sqlite-jdbc:3.43.0.0") } } - - val jvmTest by getting - - val iosX64Main by getting - val iosArm64Main by getting - val iosSimulatorArm64Main by getting - - val macosX64Main by getting - val macosArm64Main by getting - - val watchosX64Main by getting - val watchosArm32Main by getting - val watchosArm64Main by getting - val watchosSimulatorArm64Main by getting - val watchosDeviceArm64Main by getting - - val tvosX64Main by getting - val tvosArm64Main by getting - val tvosSimulatorArm64Main by getting - - val linuxX64Main by getting - - val mingwX64Main by getting - - val nativeMain by creating { - dependsOn(commonMain) - } - - val appleMain by creating { - dependsOn(nativeMain) - - iosX64Main.dependsOn(this) - iosArm64Main.dependsOn(this) - iosSimulatorArm64Main.dependsOn(this) - - macosX64Main.dependsOn(this) - macosArm64Main.dependsOn(this) - - watchosX64Main.dependsOn(this) - watchosArm32Main.dependsOn(this) - watchosArm64Main.dependsOn(this) - watchosSimulatorArm64Main.dependsOn(this) - watchosDeviceArm64Main.dependsOn(this) - - tvosX64Main.dependsOn(this) - tvosArm64Main.dependsOn(this) - tvosSimulatorArm64Main.dependsOn(this) - } - - val linuxMain by creating { - dependsOn(nativeMain) - - linuxX64Main.dependsOn(this) - } - - val mingwMain by creating { - dependsOn(nativeMain) - - mingwX64Main.dependsOn(this) - } - - val iosX64Test by getting - val iosArm64Test by getting - val iosSimulatorArm64Test by getting - - val macosX64Test by getting - val macosArm64Test by getting - - val watchosX64Test by getting - val watchosArm32Test by getting - val watchosArm64Test by getting - val watchosSimulatorArm64Test by getting - val watchosDeviceArm64Test by getting - - val tvosX64Test by getting - val tvosArm64Test by getting - val tvosSimulatorArm64Test by getting - - val linuxX64Test by getting - - val mingwX64Test by getting - - val nativeTest by creating { - dependsOn(commonTest) - } - - val appleTest by creating { - dependsOn(nativeTest) - - iosX64Test.dependsOn(this) - iosArm64Test.dependsOn(this) - iosSimulatorArm64Test.dependsOn(this) - - macosX64Test.dependsOn(this) - macosArm64Test.dependsOn(this) - - watchosX64Test.dependsOn(this) - watchosArm32Test.dependsOn(this) - watchosArm64Test.dependsOn(this) - watchosSimulatorArm64Test.dependsOn(this) - watchosDeviceArm64Test.dependsOn(this) - - tvosX64Test.dependsOn(this) - tvosArm64Test.dependsOn(this) - tvosSimulatorArm64Test.dependsOn(this) - } - - val linuxTest by creating { - dependsOn(nativeTest) - - linuxX64Test.dependsOn(this) - } - - val mingwTest by creating { - dependsOn(nativeTest) - - mingwX64Test.dependsOn(this) - } } tasks.findByName("publishLinuxX64PublicationToMavenRepository")?.enabled = HostManager.hostIsLinux @@ -300,4 +181,8 @@ publishing { useInMemoryPgpKeys(SIGNING_KEY_ID, SIGNING_KEY, SIGNING_PASSWORD) sign(publishing.publications) } +} + +tasks.withType { + compilerOptions.freeCompilerArgs.add("-Xexpect-actual-classes") } \ No newline at end of file diff --git a/sqllin-driver/src/nativeInterop/cinterop/sqlite3.def b/sqllin-driver/src/nativeInterop/cinterop/sqlite3.def index 1f607df..deb66a3 100644 --- a/sqllin-driver/src/nativeInterop/cinterop/sqlite3.def +++ b/sqllin-driver/src/nativeInterop/cinterop/sqlite3.def @@ -7,3 +7,5 @@ linkerOpts.macos_x64 = -lpthread -ldl linkerOpts.macos_arm64 = -lpthread -ldl noStringConversion = sqlite3_prepare_v2 sqlite3_prepare_v3 + +userSetupHint = message \ No newline at end of file diff --git a/sqllin-driver/src/nativeMain/kotlin/com/ctrip/sqllin/driver/cinterop/SQLiteErrorType.kt b/sqllin-driver/src/nativeMain/kotlin/com/ctrip/sqllin/driver/cinterop/SQLiteErrorType.kt index 0529bda..3025a85 100644 --- a/sqllin-driver/src/nativeMain/kotlin/com/ctrip/sqllin/driver/cinterop/SQLiteErrorType.kt +++ b/sqllin-driver/src/nativeMain/kotlin/com/ctrip/sqllin/driver/cinterop/SQLiteErrorType.kt @@ -16,11 +16,14 @@ package com.ctrip.sqllin.driver.cinterop +import kotlinx.cinterop.ExperimentalForeignApi + /** * The result codes Enum * @author yaqiao */ +@OptIn(ExperimentalForeignApi::class) internal enum class SQLiteErrorType(val code: Int) { SQLITE_OK(com.ctrip.sqllin.sqlite3.SQLITE_OK), /* Successful result */ diff --git a/sqllin-dsl/build.gradle.kts b/sqllin-dsl/build.gradle.kts index 7c13cde..f936c51 100644 --- a/sqllin-dsl/build.gradle.kts +++ b/sqllin-dsl/build.gradle.kts @@ -1,4 +1,5 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.konan.target.HostManager plugins { @@ -80,121 +81,12 @@ kotlin { } } val androidInstrumentedTest by getting { - dependsOn(commonTest) dependencies { implementation("androidx.test:core:1.5.0") implementation("androidx.test:runner:1.5.2") implementation("androidx.test:rules:1.5.0") } } - - val jvmMain by getting - - val jvmTest by getting - - val iosX64Main by getting - val iosArm64Main by getting - val iosSimulatorArm64Main by getting - - val macosX64Main by getting - val macosArm64Main by getting - - val watchosX64Main by getting - val watchosArm32Main by getting - val watchosArm64Main by getting - val watchosSimulatorArm64Main by getting - val watchosDeviceArm64Main by getting - - val tvosX64Main by getting - val tvosArm64Main by getting - val tvosSimulatorArm64Main by getting - - val linuxX64Main by getting - - val mingwX64Main by getting - - val nativeMain by creating { - dependsOn(commonMain) - - iosX64Main.dependsOn(this) - iosArm64Main.dependsOn(this) - iosSimulatorArm64Main.dependsOn(this) - - macosX64Main.dependsOn(this) - macosArm64Main.dependsOn(this) - - watchosX64Main.dependsOn(this) - watchosArm32Main.dependsOn(this) - watchosArm64Main.dependsOn(this) - watchosSimulatorArm64Main.dependsOn(this) - watchosDeviceArm64Main.dependsOn(this) - - tvosX64Main.dependsOn(this) - tvosArm64Main.dependsOn(this) - tvosSimulatorArm64Main.dependsOn(this) - - linuxX64Main.dependsOn(this) - - mingwX64Main.dependsOn(this) - } - - val iosX64Test by getting - val iosArm64Test by getting - val iosSimulatorArm64Test by getting - - val macosX64Test by getting - val macosArm64Test by getting - - val watchosX64Test by getting - val watchosArm32Test by getting - val watchosArm64Test by getting - val watchosSimulatorArm64Test by getting - val watchosDeviceArm64Test by getting - - val tvosX64Test by getting - val tvosArm64Test by getting - val tvosSimulatorArm64Test by getting - - val linuxX64Test by getting - - val mingwX64Test by getting - - val nativeTest by creating { - dependsOn(commonTest) - } - - val appleTest by creating { - dependsOn(nativeTest) - - iosX64Test.dependsOn(this) - iosArm64Test.dependsOn(this) - iosSimulatorArm64Test.dependsOn(this) - - macosX64Test.dependsOn(this) - macosArm64Test.dependsOn(this) - - watchosX64Test.dependsOn(this) - watchosArm32Test.dependsOn(this) - watchosArm64Test.dependsOn(this) - watchosSimulatorArm64Test.dependsOn(this) - watchosDeviceArm64Test.dependsOn(this) - - tvosX64Test.dependsOn(this) - tvosArm64Test.dependsOn(this) - tvosSimulatorArm64Test.dependsOn(this) - } - - val linuxTest by creating { - dependsOn(nativeTest) - - linuxX64Test.dependsOn(this) - } - - val mingwTest by creating { - dependsOn(nativeTest) - - mingwX64Test.dependsOn(this) - } } tasks.findByName("publishLinuxX64PublicationToMavenRepository")?.enabled = HostManager.hostIsLinux @@ -323,4 +215,8 @@ publishing { useInMemoryPgpKeys(SIGNING_KEY_ID, SIGNING_KEY, SIGNING_PASSWORD) sign(publishing.publications) } +} + +tasks.withType { + compilerOptions.freeCompilerArgs.add("-Xexpect-actual-classes") } \ No newline at end of file diff --git a/sqllin-dsl/src/commonMain/kotlin/com/ctrip/sqllin/dsl/DBEntity.kt b/sqllin-dsl/src/commonMain/kotlin/com/ctrip/sqllin/dsl/DBEntity.kt deleted file mode 100644 index 35e7134..0000000 --- a/sqllin-dsl/src/commonMain/kotlin/com/ctrip/sqllin/dsl/DBEntity.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2022 Ctrip.com. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.ctrip.sqllin.dsl - -import kotlinx.serialization.KSerializer - -/** - * Base where clause property in SQL - * @author yaqiao - */ - -@Deprecated(message = "The DBEntity hae benn deprecated, you don't need to implement this interface anymore") -public fun interface DBEntity { - - public fun kSerializer(): KSerializer -} \ No newline at end of file From 1ec121c549d6281915b8a82444135470ccc3d773 Mon Sep 17 00:00:00 2001 From: qiaoyuang Date: Fri, 3 Nov 2023 16:12:27 +0800 Subject: [PATCH 2/2] Fix the Android instrumented tests --- sqllin-driver/build.gradle.kts | 10 ++++------ sqllin-dsl/build.gradle.kts | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/sqllin-driver/build.gradle.kts b/sqllin-driver/build.gradle.kts index 7df2c2a..3e7808f 100644 --- a/sqllin-driver/build.gradle.kts +++ b/sqllin-driver/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.konan.target.HostManager @@ -19,6 +21,8 @@ kotlin { explicitApi() androidTarget { publishLibraryVariants("release") + @OptIn(ExperimentalKotlinGradlePluginApi::class) + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) } jvm { @@ -98,12 +102,6 @@ android { minSdk = 23 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } - testOptions { - unitTests { - isReturnDefaultValues = true - isIncludeAndroidResources = true - } - } compileOptions { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17 diff --git a/sqllin-dsl/build.gradle.kts b/sqllin-dsl/build.gradle.kts index f936c51..e77d7d9 100644 --- a/sqllin-dsl/build.gradle.kts +++ b/sqllin-dsl/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.konan.target.HostManager @@ -21,6 +23,8 @@ kotlin { explicitApi() androidTarget { publishLibraryVariants("release") + @OptIn(ExperimentalKotlinGradlePluginApi::class) + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) } jvm { @@ -100,12 +104,6 @@ android { minSdk = 23 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } - testOptions { - unitTests { - isReturnDefaultValues = true - isIncludeAndroidResources = true - } - } compileOptions { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17