Skip to content

Upgrade to KSP2 #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-34
key: avd-35

- name: Create AVD and Generate Snapshot for Caching
if: steps.avd-cache.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -154,10 +154,10 @@ jobs:
run: ./gradlew :sqllin-dsl:mingwX64MainKlibrary

- name: Run sqllin-dsl MinGW X64 Tests
run: ./gradlew :sqllin-dsl:cleanMingwX64Test && ./gradlew :sqllin-dsl:mingwX64Test --stacktrace
run: ./gradlew :sqllin-dsl-test:cleanMingwX64Test && ./gradlew :sqllin-dsl-test:mingwX64Test --stacktrace

- name: Run sqllin-dsl JVM Unit Tests on MinGW X64
run: ./gradlew :sqllin-dsl:cleanJvmTest && ./gradlew :sqllin-dsl:jvmTest --stacktrace
run: ./gradlew :sqllin-dsl-test:cleanJvmTest && ./gradlew :sqllin-dsl-test:jvmTest --stacktrace

- name: Upload sqllin-driver Reports
uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local.properties
/sqllin-driver/build
/sqllin-dsl/build
/sqllin-processor/build
/sqllin-dsl-test/build
/sample/build
*.podspec
.kotlin
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

- Date format: YYYY-MM-dd

## v1.4.3 / 2025-06-02

### All

* Update `Kotlin`'s version to `2.1.21`

### sqllin-processor

* Update `KSP`'s version to `2.1.21-2.0.1`

## v1.4.2 / 2025-04-23

### All
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VERSION=1.4.2
VERSION=1.4.3
GROUP=com.ctrip.kotlin

#Maven Publish Information
#Maven Publishing Information
githubURL=https://github.com/ctripcorp/SQLlin
licenseName=The Apache License, Version 2.0
licenseURL=https://www.apache.org/licenses/LICENSE-2.0.txt
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[versions]

kotlin = "2.1.20"
agp = "8.9.2"
ksp = "2.1.20-1.0.32"
kotlin = "2.1.21"
agp = "8.9.3"
ksp = "2.1.21-2.0.1"
serialization = "1.8.1"
coroutines = "1.10.2"
androidx-annotation = "1.9.1"
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 @@
#Tue Mar 08 15:11:46 CST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ rootProject.name = "SQLlin"
include(":sqllin-driver")
include(":sqllin-dsl")
include(":sqllin-processor")
include(":sqllin-dsl-test")
include(":sample")

pluginManagement {
Expand Down
5 changes: 5 additions & 0 deletions sqllin-dsl-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Test Module for _sqllin-dsl_

中文版请见[这里](README_CN.md)

>**Note: This is not an unit test tool for _sqllin-dsl_, it's the main implementations of unit tests for _sqllin-dsl_. Due to KSP doesn't support generating code for `commonTest` at the moment, I put all code of _sqllin-dsl_'s unit tests in this module.**
3 changes: 3 additions & 0 deletions sqllin-dsl-test/README_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# _sqllin-dsl_ 的测试模块

>**注意:这不是 _sqllin-dsl_ 的单元测试工具,而是 _sqllin-dsl_ 单元测试的主要实现。由于 KSP 当前不支持为 `commonTest` 生成代码,因此我将 _sqllin-dsl_ 的单元测试的所有代码都放在了本模块中。**
121 changes: 121 additions & 0 deletions sqllin-dsl-test/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import org.jetbrains.kotlin.konan.target.HostManager
import kotlin.collections.plusAssign

plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.kotlinx.serialization)
alias(libs.plugins.android.library)
alias(libs.plugins.ksp)
}

version = "1.0"

@OptIn(ExperimentalKotlinGradlePluginApi::class)
kotlin {
jvmToolchain(21)
androidTarget {
publishLibraryVariants("release")
instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test)
}

jvm {
compilerOptions.jvmTarget.set(JvmTarget.JVM_11)
}

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64(),

macosX64(),
macosArm64(),

watchosArm32(),
watchosArm64(),
watchosX64(),
watchosSimulatorArm64(),
watchosDeviceArm64(),

tvosArm64(),
tvosX64(),
tvosSimulatorArm64(),

linuxX64(),
linuxArm64(),

mingwX64(),
).forEach {
it.setupNativeConfig()
}

compilerOptions {
freeCompilerArgs.add("-Xexpect-actual-classes")
}

sourceSets {
all {
languageSettings.optIn("kotlin.RequiresOptIn")
}
commonMain {
kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin")
dependencies {
implementation(project(":sqllin-dsl"))
implementation(libs.kotlinx.serialization)
implementation(libs.kotlinx.coroutines)
}
}
commonTest.dependencies {
implementation(kotlin("test"))
}
androidInstrumentedTest {
dependencies {
implementation(libs.androidx.test.core)
implementation(libs.androidx.test.runner)
implementation(libs.androidx.test.rules)
}
}
}
}

android {
namespace = "com.ctrip.sqllin.dsl.test"
compileSdk = 35
defaultConfig {
minSdk = 23
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
}
}

fun KotlinNativeTarget.setupNativeConfig() {
binaries {
all {
linkerOpts += when {
HostManager.hostIsLinux -> listOf("-lsqlite3", "-L$rootDir/libs/linux", "-L/usr/lib/x86_64-linux-gnu", "-L/usr/lib", "-L/usr/lib64")
HostManager.hostIsMingw -> listOf("-Lc:\\msys64\\mingw64\\lib", "-L$rootDir\\libs\\windows", "-lsqlite3")
else -> listOf("-lsqlite3")
}
}
}
}

dependencies {
coreLibraryDesugaring(libs.desugar.jdk.libs)
add("kspCommonMainMetadata", project(":sqllin-processor"))
}

afterEvaluate { // WORKAROUND: both register() and named() fail – https://github.com/gradle/gradle/issues/9331
tasks {
withType<KotlinCompilationTask<*>> {
if (name != "kspCommonMainKotlinMetadata")
dependsOn("kspCommonMainKotlinMetadata")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
/*
* 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
package com.ctrip.sqllin.dsl.test

import android.content.Context
import androidx.test.core.app.ApplicationProvider
Expand Down
2 changes: 2 additions & 0 deletions sqllin-dsl-test/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.ctrip.sqllin.dsl.test" />
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.ctrip.sqllin.dsl
package com.ctrip.sqllin.dsl.test

import kotlinx.cinterop.UnsafeNumber
import platform.Foundation.NSDocumentDirectory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.ctrip.sqllin.dsl
package com.ctrip.sqllin.dsl.test

import com.ctrip.sqllin.dsl.annotation.DBRow
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.ctrip.sqllin.dsl
package com.ctrip.sqllin.dsl.test

import com.ctrip.sqllin.dsl.annotation.DBRow
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
* limitations under the License.
*/

package com.ctrip.sqllin.dsl
package com.ctrip.sqllin.dsl.test

import com.ctrip.sqllin.driver.DatabaseConfiguration
import com.ctrip.sqllin.driver.DatabasePath
import com.ctrip.sqllin.dsl.Database
import com.ctrip.sqllin.dsl.sql.X
import com.ctrip.sqllin.dsl.sql.clause.*
import com.ctrip.sqllin.dsl.sql.clause.OrderByWay.ASC
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
/*
* Copyright (C) 2023 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
package com.ctrip.sqllin.dsl.test

import com.ctrip.sqllin.driver.deleteDatabase
import com.ctrip.sqllin.driver.toDatabasePath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.ctrip.sqllin.dsl
package com.ctrip.sqllin.dsl.test

import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.cinterop.toKString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.ctrip.sqllin.dsl
package com.ctrip.sqllin.dsl.test

import kotlinx.cinterop.*
import platform.posix._wgetcwd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.ctrip.sqllin.dsl
package com.ctrip.sqllin.dsl.test

import com.ctrip.sqllin.driver.deleteDatabase
import com.ctrip.sqllin.driver.toDatabasePath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.ctrip.sqllin.dsl
package com.ctrip.sqllin.dsl.test

/**
* Some platform-related functions
Expand Down
Loading