diff --git a/CHANGELOG.md b/CHANGELOG.md index de1e94cd..6ee01ee1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## 1.2.0 (pending) +## 1.2.0 * Add a new sync client implementation written in Rust instead of Kotlin. While this client is still experimental, we intend to make it the default in the future. The main benefit of this client is diff --git a/core/build.gradle.kts b/core/build.gradle.kts index f66edfa5..32dec68d 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -6,7 +6,9 @@ import org.gradle.internal.os.OperatingSystem import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest import org.jetbrains.kotlin.gradle.tasks.KotlinTest - +import java.nio.file.Path +import kotlin.io.path.createDirectories +import kotlin.io.path.writeText plugins { alias(libs.plugins.kotlinMultiplatform) @@ -125,6 +127,32 @@ val moveJDBCJNIFiles by tasks.registering(Copy::class) { into(jniLibsFolder) // Move everything into the base jniLibs folder } +val generateVersionConstant by tasks.registering { + val target = project.layout.buildDirectory.dir("generated/constants") + val packageName = "com.powersync.build" + + outputs.dir(target) + val currentVersion = version.toString() + + doLast { + val dir = target.get().asFile + dir.mkdir() + val rootPath = dir.toPath() + + val source = """ + package $packageName + + internal const val LIBRARY_VERSION: String = "$currentVersion" + + """.trimIndent() + + val packageRoot = packageName.split('.').fold(rootPath, Path::resolve) + packageRoot.createDirectories() + + packageRoot.resolve("BuildConstants.kt").writeText(source) + } +} + kotlin { powersyncTargets() @@ -134,17 +162,6 @@ kotlin { compilerOptions.freeCompilerArgs.add("-Xexport-kdoc") } } - - /* - If we ever need macOS support: - { - binaries.withType().configureEach { - linkTaskProvider.dependsOn(downloadPowersyncDesktopBinaries) - linkerOpts("-lpowersync") - linkerOpts("-L", binariesFolder.map { it.dir("powersync") }.get().asFile.path) - } - } - */ } explicitApi() @@ -168,21 +185,27 @@ kotlin { } } - commonMain.dependencies { - implementation(libs.uuid) - implementation(libs.kotlin.stdlib) - implementation(libs.ktor.client.core) - implementation(libs.ktor.client.contentnegotiation) - implementation(libs.ktor.serialization.json) - implementation(libs.kotlinx.io) - implementation(libs.rsocket.core) - implementation(libs.rsocket.transport.websocket) - implementation(libs.kotlinx.coroutines.core) - implementation(libs.kotlinx.datetime) - implementation(libs.stately.concurrency) - implementation(libs.configuration.annotations) - api(projects.persistence) - api(libs.kermit) + commonMain.configure { + kotlin { + srcDir(generateVersionConstant) + } + + dependencies { + implementation(libs.uuid) + implementation(libs.kotlin.stdlib) + implementation(libs.ktor.client.core) + implementation(libs.ktor.client.contentnegotiation) + implementation(libs.ktor.serialization.json) + implementation(libs.kotlinx.io) + implementation(libs.rsocket.core) + implementation(libs.rsocket.transport.websocket) + implementation(libs.kotlinx.coroutines.core) + implementation(libs.kotlinx.datetime) + implementation(libs.stately.concurrency) + implementation(libs.configuration.annotations) + api(projects.persistence) + api(libs.kermit) + } } androidMain { diff --git a/core/src/androidMain/kotlin/com/powersync/sync/UserAgent.android.kt b/core/src/androidMain/kotlin/com/powersync/sync/UserAgent.android.kt index 67d9ad94..19502709 100644 --- a/core/src/androidMain/kotlin/com/powersync/sync/UserAgent.android.kt +++ b/core/src/androidMain/kotlin/com/powersync/sync/UserAgent.android.kt @@ -1,5 +1,6 @@ package com.powersync.sync import android.os.Build +import com.powersync.build.LIBRARY_VERSION -internal actual fun userAgent(): String = "PowerSync Kotlin SDK (Android ${Build.VERSION.SDK_INT})" +internal actual fun userAgent(): String = "PowerSync Kotlin SDK v$LIBRARY_VERSION (Android ${Build.VERSION.SDK_INT})" diff --git a/core/src/jvmMain/kotlin/com/powersync/sync/UserAgent.jvm.kt b/core/src/jvmMain/kotlin/com/powersync/sync/UserAgent.jvm.kt index fd5cf264..704f9570 100644 --- a/core/src/jvmMain/kotlin/com/powersync/sync/UserAgent.jvm.kt +++ b/core/src/jvmMain/kotlin/com/powersync/sync/UserAgent.jvm.kt @@ -1,9 +1,11 @@ package com.powersync.sync +import com.powersync.build.LIBRARY_VERSION + internal actual fun userAgent(): String { val os = System.getProperty("os.name") ?: "unknown" val osVersion = System.getProperty("os.version") ?: "" val java = System.getProperty("java.vendor.version") ?: System.getProperty("java.runtime.version") ?: "unknown" - return "PowerSync Kotlin SDK (running Java $java on $os $osVersion)" + return "PowerSync Kotlin SDK v${LIBRARY_VERSION} (running Java $java on $os $osVersion)" } diff --git a/core/src/nativeMain/kotlin/com/powersync/sync/UserAgent.native.kt b/core/src/nativeMain/kotlin/com/powersync/sync/UserAgent.native.kt index 5a189a8b..eff15b7f 100644 --- a/core/src/nativeMain/kotlin/com/powersync/sync/UserAgent.native.kt +++ b/core/src/nativeMain/kotlin/com/powersync/sync/UserAgent.native.kt @@ -1,6 +1,8 @@ package com.powersync.sync +import com.powersync.build.LIBRARY_VERSION import kotlin.experimental.ExperimentalNativeApi @OptIn(ExperimentalNativeApi::class) -internal actual fun userAgent(): String = "PowerSync Kotlin SDK (running on ${Platform.cpuArchitecture.name} ${Platform.osFamily.name})" +internal actual fun userAgent(): String = + "PowerSync Kotlin SDK v$LIBRARY_VERSION (running on ${Platform.cpuArchitecture.name} ${Platform.osFamily.name})" diff --git a/gradle.properties b/gradle.properties index 6c4128c3..72a3ad75 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,7 +18,7 @@ development=true RELEASE_SIGNING_ENABLED=true # Library config GROUP=com.powersync -LIBRARY_VERSION=1.1.1 +LIBRARY_VERSION=1.2.0 GITHUB_REPO=https://github.com/powersync-ja/powersync-kotlin.git # POM POM_URL=https://github.com/powersync-ja/powersync-kotlin/