From 01abf5f9d7decdfcf62c49736c69869688988221 Mon Sep 17 00:00:00 2001 From: qiaoyuang <qiaoyuang2012@gmail.com> Date: Wed, 4 Dec 2024 09:42:29 +0000 Subject: [PATCH] Update to Kotlin 2.1.0 --- .github/workflows/build.yml | 12 +-- .github/workflows/publish.yml | 12 +-- CHANGELOG.md | 12 +-- gradle.properties | 1 + gradle/libs.versions.toml | 14 +-- sample/build.gradle.kts | 8 +- sqllin-driver/build.gradle.kts | 35 +++----- sqllin-dsl/build.gradle.kts | 87 ++++++++++++++++--- .../com/ctrip/sqllin/dsl/CommonBasicTest.kt | 0 .../kotlin/com/ctrip/sqllin/dsl/Entities.kt | 0 .../sqllin/dsl/TestPrimitiveTypeForKSP.kt | 0 .../kotlin/com/ctrip/sqllin/dsl/NativeTest.kt | 0 .../kotlin/com/ctrip/sqllin/dsl/Platform.kt | 0 sqllin-processor/build.gradle.kts | 4 +- .../ctrip/sqllin/processor/ClauseProcessor.kt | 2 +- 15 files changed, 119 insertions(+), 68 deletions(-) rename sqllin-dsl/src/{commonTest => commonTestCode}/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt (100%) rename sqllin-dsl/src/{commonTest => commonTestCode}/kotlin/com/ctrip/sqllin/dsl/Entities.kt (100%) rename sqllin-dsl/src/{commonTest => commonTestCode}/kotlin/com/ctrip/sqllin/dsl/TestPrimitiveTypeForKSP.kt (100%) rename sqllin-dsl/src/{nativeTest => nativeTestCode}/kotlin/com/ctrip/sqllin/dsl/NativeTest.kt (100%) rename sqllin-dsl/src/{nativeTest => nativeTestCode}/kotlin/com/ctrip/sqllin/dsl/Platform.kt (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b6919d8..3105435 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,11 +28,11 @@ jobs: - name: Validate Gradle Wrapper uses: gradle/wrapper-validation-action@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 17 + java-version: 21 - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 @@ -124,11 +124,11 @@ jobs: - name: Validate Gradle Wrapper uses: gradle/wrapper-validation-action@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 17 + java-version: 21 - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 @@ -184,11 +184,11 @@ jobs: - name: Validate Gradle Wrapper uses: gradle/wrapper-validation-action@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 17 + java-version: 21 - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 767f705..f1abe65 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,11 +23,11 @@ jobs: - name: Validate Gradle Wrapper uses: gradle/wrapper-validation-action@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 17 + java-version: 21 - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 @@ -60,11 +60,11 @@ jobs: - name: Validate Gradle Wrapper uses: gradle/wrapper-validation-action@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 17 + java-version: 21 - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 @@ -97,11 +97,11 @@ jobs: - name: Validate Gradle Wrapper uses: gradle/wrapper-validation-action@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 17 + java-version: 21 - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 14d3177..0f2a24b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,24 +2,24 @@ - Date format: YYYY-MM-dd -## v1.4.0 / 2024-09-02 +## v1.4.0 / 2024-12-04 ### All -* Update `Kotlin`'s version to `2.0.20` +* Update `Kotlin`'s version to `2.1.00` ### sqllin-dsl -* Update `kotlinx.coroutines`'s version to `1.8.1` -* Update `kotlinx.serialization`'s version to `1.7.2` +* Update `kotlinx.coroutines`'s version to `1.9.0` +* Update `kotlinx.serialization`'s version to `1.7.3` ### sqllin-driver -* Update the `sqlite-jdbc`'s version to `3.46.1.0` +* Update the `sqlite-jdbc`'s version to `3.47.1.0` ### sqllin-processor -* Update `KSP`'s version to `2.0.20-1.0.24` +* Update `KSP`'s version to `2.1.0-1.0.29` ## v1.3.2 / 2024-06-18 diff --git a/gradle.properties b/gradle.properties index 512a292..f91490f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -27,4 +27,5 @@ kotlin.code.style=official kotlin.mpp.stability.nowarn=true kotlin.mpp.enableCInteropCommonization=true kotlin.natvie.increment=true +ksp.useKSP2=true #kotlin.compiler.execution.strategy=out-of-process \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4ade688..8152c7c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,14 +1,14 @@ [versions] -kotlin = "2.0.20" -agp = "8.5.2" -ksp = "2.0.20-1.0.24" -serialization = "1.7.2" -coroutines = "1.8.1" -androidx-annotation = "1.8.2" +kotlin = "2.1.0" +agp = "8.7.3" +ksp = "2.1.0-1.0.29" +serialization = "1.7.3" +coroutines = "1.9.0" +androidx-annotation = "1.9.1" androidx-test = "1.6.1" androidx-test-runner = "1.6.2" -sqlite-jdbc = "3.46.1.0" +sqlite-jdbc = "3.47.1.0" [libraries] diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts index 04f736f..8d788b0 100644 --- a/sample/build.gradle.kts +++ b/sample/build.gradle.kts @@ -1,4 +1,3 @@ -import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask @@ -11,7 +10,6 @@ plugins { version = "1.0" -@OptIn(ExperimentalKotlinGradlePluginApi::class) kotlin { androidTarget { publishLibraryVariants("release") @@ -31,7 +29,7 @@ kotlin { all { languageSettings.optIn("kotlin.RequiresOptIn") } - val commonMain by getting { + commonMain { kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin") dependencies { implementation(project(":sqllin-dsl")) @@ -44,13 +42,13 @@ kotlin { android { namespace = "com.ctrip.sqllin.sample" - compileSdk = 34 + compileSdk = 35 defaultConfig { minSdk = 23 } compileOptions { sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_21 } } diff --git a/sqllin-driver/build.gradle.kts b/sqllin-driver/build.gradle.kts index 1fbe9d4..72424d6 100644 --- a/sqllin-driver/build.gradle.kts +++ b/sqllin-driver/build.gradle.kts @@ -65,29 +65,20 @@ kotlin { optIn("kotlin.RequiresOptIn") } } - val commonTest by getting { - dependencies { - implementation(kotlin("test")) - implementation(libs.kotlinx.coroutines) - } + commonTest.dependencies { + implementation(kotlin("test")) + implementation(libs.kotlinx.coroutines) } - val androidMain by getting { - dependencies { - implementation(libs.androidx.annotation) - } + androidMain.dependencies { + implementation(libs.androidx.annotation) } - val androidInstrumentedTest by getting { - dependencies { - implementation(libs.androidx.test.core) - implementation(libs.androidx.test.runner) - implementation(libs.androidx.test.rules) - } + androidInstrumentedTest.dependencies { + implementation(libs.androidx.test.core) + implementation(libs.androidx.test.runner) + implementation(libs.androidx.test.rules) } - - val jvmMain by getting { - dependencies { - implementation(libs.sqlite.jdbc) - } + jvmMain.dependencies { + implementation(libs.sqlite.jdbc) } } } @@ -109,14 +100,14 @@ gradle.taskGraph.whenReady { android { namespace = "com.ctrip.sqllin.driver" - compileSdk = 34 + compileSdk = 35 defaultConfig { minSdk = 23 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } compileOptions { sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_21 } } diff --git a/sqllin-dsl/build.gradle.kts b/sqllin-dsl/build.gradle.kts index 79d6f1c..cc2cb83 100644 --- a/sqllin-dsl/build.gradle.kts +++ b/sqllin-dsl/build.gradle.kts @@ -1,5 +1,6 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.konan.target.HostManager @@ -67,28 +68,86 @@ kotlin { optIn("kotlin.RequiresOptIn") } } - val commonMain by getting { - dependencies { - api(project(":sqllin-driver")) - implementation(libs.kotlinx.serialization) - implementation(libs.kotlinx.coroutines) - } + commonMain.dependencies { + api(project(":sqllin-driver")) + implementation(libs.kotlinx.serialization) + implementation(libs.kotlinx.coroutines) } - val commonTest by getting { - dependencies { - implementation(kotlin("test")) - } + commonTest.dependencies { + implementation(kotlin("test")) } - val androidInstrumentedTest by getting { + androidInstrumentedTest { + setCommonTestDir() dependencies { implementation(libs.androidx.test.core) implementation(libs.androidx.test.runner) implementation(libs.androidx.test.rules) } } + jvmTest { + setCommonTestDir() + } + + iosX64Test { + setNativeTestDir() + } + iosArm64Test { + setNativeTestDir() + } + iosSimulatorArm64Test { + setNativeTestDir() + } + + + macosX64Test { + setNativeTestDir() + } + macosArm64Test { + setNativeTestDir() + } + + watchosX64Test { + setNativeTestDir() + } + watchosArm32Test { + setNativeTestDir() + } + watchosArm64Test { + setNativeTestDir() + } + watchosDeviceArm64Test { + setNativeTestDir() + } + watchosSimulatorArm64Test { + setNativeTestDir() + } + + tvosX64Test { + setNativeTestDir() + } + tvosArm64Test { + setNativeTestDir() + } + tvosSimulatorArm64Test { + setNativeTestDir() + } + + linuxX64Test { + setNativeTestDir() + } + linuxArm64Test { + setNativeTestDir() + } + + mingwX64Test { + setNativeTestDir() + } } } +fun KotlinSourceSet.setCommonTestDir(vararg path: String) = kotlin.srcDirs("src/commonTestCode/kotlin", path) +fun KotlinSourceSet.setNativeTestDir() = setCommonTestDir("src/nativeTestCode/kotlin") + gradle.taskGraph.whenReady { if (!project.hasProperty("onCICD")) return@whenReady @@ -106,14 +165,14 @@ gradle.taskGraph.whenReady { android { namespace = "com.ctrip.sqllin.dsl" - compileSdk = 34 + compileSdk = 35 defaultConfig { minSdk = 23 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } compileOptions { sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_21 } } @@ -145,6 +204,7 @@ dependencies { "kspWatchosX64Test", "kspWatchosArm32Test", "kspWatchosArm64Test", + "kspWatchosDeviceArm64Test", "kspWatchosSimulatorArm64Test", "kspTvosX64Test", @@ -152,6 +212,7 @@ dependencies { "kspTvosSimulatorArm64Test", "kspLinuxX64Test", + "kspLinuxArm64Test", "kspMingwX64Test", ) diff --git a/sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt b/sqllin-dsl/src/commonTestCode/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt similarity index 100% rename from sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt rename to sqllin-dsl/src/commonTestCode/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt diff --git a/sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/Entities.kt b/sqllin-dsl/src/commonTestCode/kotlin/com/ctrip/sqllin/dsl/Entities.kt similarity index 100% rename from sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/Entities.kt rename to sqllin-dsl/src/commonTestCode/kotlin/com/ctrip/sqllin/dsl/Entities.kt diff --git a/sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/TestPrimitiveTypeForKSP.kt b/sqllin-dsl/src/commonTestCode/kotlin/com/ctrip/sqllin/dsl/TestPrimitiveTypeForKSP.kt similarity index 100% rename from sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/TestPrimitiveTypeForKSP.kt rename to sqllin-dsl/src/commonTestCode/kotlin/com/ctrip/sqllin/dsl/TestPrimitiveTypeForKSP.kt diff --git a/sqllin-dsl/src/nativeTest/kotlin/com/ctrip/sqllin/dsl/NativeTest.kt b/sqllin-dsl/src/nativeTestCode/kotlin/com/ctrip/sqllin/dsl/NativeTest.kt similarity index 100% rename from sqllin-dsl/src/nativeTest/kotlin/com/ctrip/sqllin/dsl/NativeTest.kt rename to sqllin-dsl/src/nativeTestCode/kotlin/com/ctrip/sqllin/dsl/NativeTest.kt diff --git a/sqllin-dsl/src/nativeTest/kotlin/com/ctrip/sqllin/dsl/Platform.kt b/sqllin-dsl/src/nativeTestCode/kotlin/com/ctrip/sqllin/dsl/Platform.kt similarity index 100% rename from sqllin-dsl/src/nativeTest/kotlin/com/ctrip/sqllin/dsl/Platform.kt rename to sqllin-dsl/src/nativeTestCode/kotlin/com/ctrip/sqllin/dsl/Platform.kt diff --git a/sqllin-processor/build.gradle.kts b/sqllin-processor/build.gradle.kts index 5b0dd36..0f3855d 100644 --- a/sqllin-processor/build.gradle.kts +++ b/sqllin-processor/build.gradle.kts @@ -15,8 +15,8 @@ repositories { } java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } dependencies { diff --git a/sqllin-processor/src/main/kotlin/com/ctrip/sqllin/processor/ClauseProcessor.kt b/sqllin-processor/src/main/kotlin/com/ctrip/sqllin/processor/ClauseProcessor.kt index 8784114..83cef04 100644 --- a/sqllin-processor/src/main/kotlin/com/ctrip/sqllin/processor/ClauseProcessor.kt +++ b/sqllin-processor/src/main/kotlin/com/ctrip/sqllin/processor/ClauseProcessor.kt @@ -51,7 +51,7 @@ class ClauseProcessor( for (classDeclaration in validateDBRowClasses) { if (classDeclaration.annotations.all { !it.annotationType.resolve().isAssignableFrom(serializableType) }) - continue // Don't handle the class that don't annotated 'Serializable' + continue // Don't handle the classes that didn't be annotated 'Serializable' val className = classDeclaration.simpleName.asString() val packageName = classDeclaration.packageName.asString()