Skip to content

Commit fafc018

Browse files
authored
Include version number in user agent, prepare release (#203)
1 parent a5fe67b commit fafc018

File tree

6 files changed

+60
-32
lines changed

6 files changed

+60
-32
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
## 1.2.0 (pending)
3+
## 1.2.0
44

55
* Add a new sync client implementation written in Rust instead of Kotlin. While this client is still
66
experimental, we intend to make it the default in the future. The main benefit of this client is

core/build.gradle.kts

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import org.gradle.internal.os.OperatingSystem
66
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
77
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
88
import org.jetbrains.kotlin.gradle.tasks.KotlinTest
9-
9+
import java.nio.file.Path
10+
import kotlin.io.path.createDirectories
11+
import kotlin.io.path.writeText
1012

1113
plugins {
1214
alias(libs.plugins.kotlinMultiplatform)
@@ -125,6 +127,32 @@ val moveJDBCJNIFiles by tasks.registering(Copy::class) {
125127
into(jniLibsFolder) // Move everything into the base jniLibs folder
126128
}
127129

130+
val generateVersionConstant by tasks.registering {
131+
val target = project.layout.buildDirectory.dir("generated/constants")
132+
val packageName = "com.powersync.build"
133+
134+
outputs.dir(target)
135+
val currentVersion = version.toString()
136+
137+
doLast {
138+
val dir = target.get().asFile
139+
dir.mkdir()
140+
val rootPath = dir.toPath()
141+
142+
val source = """
143+
package $packageName
144+
145+
internal const val LIBRARY_VERSION: String = "$currentVersion"
146+
147+
""".trimIndent()
148+
149+
val packageRoot = packageName.split('.').fold(rootPath, Path::resolve)
150+
packageRoot.createDirectories()
151+
152+
packageRoot.resolve("BuildConstants.kt").writeText(source)
153+
}
154+
}
155+
128156
kotlin {
129157
powersyncTargets()
130158

@@ -134,17 +162,6 @@ kotlin {
134162
compilerOptions.freeCompilerArgs.add("-Xexport-kdoc")
135163
}
136164
}
137-
138-
/*
139-
If we ever need macOS support:
140-
{
141-
binaries.withType<TestExecutable>().configureEach {
142-
linkTaskProvider.dependsOn(downloadPowersyncDesktopBinaries)
143-
linkerOpts("-lpowersync")
144-
linkerOpts("-L", binariesFolder.map { it.dir("powersync") }.get().asFile.path)
145-
}
146-
}
147-
*/
148165
}
149166

150167
explicitApi()
@@ -168,21 +185,27 @@ kotlin {
168185
}
169186
}
170187

171-
commonMain.dependencies {
172-
implementation(libs.uuid)
173-
implementation(libs.kotlin.stdlib)
174-
implementation(libs.ktor.client.core)
175-
implementation(libs.ktor.client.contentnegotiation)
176-
implementation(libs.ktor.serialization.json)
177-
implementation(libs.kotlinx.io)
178-
implementation(libs.rsocket.core)
179-
implementation(libs.rsocket.transport.websocket)
180-
implementation(libs.kotlinx.coroutines.core)
181-
implementation(libs.kotlinx.datetime)
182-
implementation(libs.stately.concurrency)
183-
implementation(libs.configuration.annotations)
184-
api(projects.persistence)
185-
api(libs.kermit)
188+
commonMain.configure {
189+
kotlin {
190+
srcDir(generateVersionConstant)
191+
}
192+
193+
dependencies {
194+
implementation(libs.uuid)
195+
implementation(libs.kotlin.stdlib)
196+
implementation(libs.ktor.client.core)
197+
implementation(libs.ktor.client.contentnegotiation)
198+
implementation(libs.ktor.serialization.json)
199+
implementation(libs.kotlinx.io)
200+
implementation(libs.rsocket.core)
201+
implementation(libs.rsocket.transport.websocket)
202+
implementation(libs.kotlinx.coroutines.core)
203+
implementation(libs.kotlinx.datetime)
204+
implementation(libs.stately.concurrency)
205+
implementation(libs.configuration.annotations)
206+
api(projects.persistence)
207+
api(libs.kermit)
208+
}
186209
}
187210

188211
androidMain {
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.powersync.sync
22

33
import android.os.Build
4+
import com.powersync.build.LIBRARY_VERSION
45

5-
internal actual fun userAgent(): String = "PowerSync Kotlin SDK (Android ${Build.VERSION.SDK_INT})"
6+
internal actual fun userAgent(): String = "PowerSync Kotlin SDK v$LIBRARY_VERSION (Android ${Build.VERSION.SDK_INT})"
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.powersync.sync
22

3+
import com.powersync.build.LIBRARY_VERSION
4+
35
internal actual fun userAgent(): String {
46
val os = System.getProperty("os.name") ?: "unknown"
57
val osVersion = System.getProperty("os.version") ?: ""
68
val java = System.getProperty("java.vendor.version") ?: System.getProperty("java.runtime.version") ?: "unknown"
79

8-
return "PowerSync Kotlin SDK (running Java $java on $os $osVersion)"
10+
return "PowerSync Kotlin SDK v${LIBRARY_VERSION} (running Java $java on $os $osVersion)"
911
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.powersync.sync
22

3+
import com.powersync.build.LIBRARY_VERSION
34
import kotlin.experimental.ExperimentalNativeApi
45

56
@OptIn(ExperimentalNativeApi::class)
6-
internal actual fun userAgent(): String = "PowerSync Kotlin SDK (running on ${Platform.cpuArchitecture.name} ${Platform.osFamily.name})"
7+
internal actual fun userAgent(): String =
8+
"PowerSync Kotlin SDK v$LIBRARY_VERSION (running on ${Platform.cpuArchitecture.name} ${Platform.osFamily.name})"

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ development=true
1818
RELEASE_SIGNING_ENABLED=true
1919
# Library config
2020
GROUP=com.powersync
21-
LIBRARY_VERSION=1.1.1
21+
LIBRARY_VERSION=1.2.0
2222
GITHUB_REPO=https://github.com/powersync-ja/powersync-kotlin.git
2323
# POM
2424
POM_URL=https://github.com/powersync-ja/powersync-kotlin/

0 commit comments

Comments
 (0)