Skip to content

Include version number in user agent, prepare release #203

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 3 commits into from
Jun 19, 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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
77 changes: 50 additions & 27 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()

Expand All @@ -134,17 +162,6 @@ kotlin {
compilerOptions.freeCompilerArgs.add("-Xexport-kdoc")
}
}

/*
If we ever need macOS support:
{
binaries.withType<TestExecutable>().configureEach {
linkTaskProvider.dependsOn(downloadPowersyncDesktopBinaries)
linkerOpts("-lpowersync")
linkerOpts("-L", binariesFolder.map { it.dir("powersync") }.get().asFile.path)
}
}
*/
}

explicitApi()
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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})"
4 changes: 3 additions & 1 deletion core/src/jvmMain/kotlin/com/powersync/sync/UserAgent.jvm.kt
Original file line number Diff line number Diff line change
@@ -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)"
}
Original file line number Diff line number Diff line change
@@ -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})"
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down