Skip to content

Commit bbe0ecc

Browse files
authored
Merge pull request #127 from powersync-ja/chore/jdk8
Support Java 8
2 parents ec8ef51 + b6e0733 commit bbe0ecc

File tree

20 files changed

+451
-258
lines changed

20 files changed

+451
-258
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.0.0-BETA25
4+
5+
* JVM: Lower minimum supported version from 17 to 8.
6+
37
## 1.0.0-BETA24
48

59
* Improve internal handling of watch queries to avoid issues where updates are not being received due to transaction commits occurring after the query is run.

build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ allprojects {
5151
exclude(group = "ai.grazie.model")
5252
exclude(group = "ai.grazie.utils")
5353
exclude(group = "ai.grazie.nlp")
54+
55+
// We have a transitive dependency on this due to Kermit, but need the fixed version to support Java 8
56+
resolutionStrategy.force("co.touchlab:stately-collections:${libs.versions.stately.get()}")
5457
}
5558

5659
//

core/build.gradle.kts

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import app.cash.sqldelight.core.capitalize
22
import com.powersync.plugins.sonatype.setupGithubRepository
33
import de.undercouch.gradle.tasks.download.Download
44
import org.gradle.internal.os.OperatingSystem
5+
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
6+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
57
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
8+
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
69
import java.util.*
710

811
plugins {
@@ -76,8 +79,20 @@ val buildCInteropDef by tasks.registering {
7679
kotlin {
7780
androidTarget {
7881
publishLibraryVariants("release", "debug")
82+
83+
@OptIn(ExperimentalKotlinGradlePluginApi::class)
84+
compilerOptions {
85+
jvmTarget.set(JvmTarget.JVM_17)
86+
}
87+
}
88+
jvm {
89+
@OptIn(ExperimentalKotlinGradlePluginApi::class)
90+
compilerOptions {
91+
jvmTarget.set(JvmTarget.JVM_1_8)
92+
// https://jakewharton.com/kotlins-jdk-release-compatibility-flag/
93+
freeCompilerArgs.add("-Xjdk-release=8")
94+
}
7995
}
80-
jvm()
8196

8297
iosX64()
8398
iosArm64()
@@ -147,8 +162,8 @@ kotlin {
147162
}
148163

149164
android {
150-
kotlin {
151-
jvmToolchain(17)
165+
compileOptions {
166+
targetCompatibility = JavaVersion.VERSION_17
152167
}
153168

154169
buildFeatures {
@@ -339,6 +354,22 @@ tasks.named<ProcessResources>(kotlin.jvm().compilations["main"].processResources
339354
from(getBinaries, downloadPowersyncDesktopBinaries)
340355
}
341356

357+
// We want to build with recent JDKs, but need to make sure we support Java 8. https://jakewharton.com/build-on-latest-java-test-through-lowest-java/
358+
val testWithJava8 by tasks.registering(KotlinJvmTest::class) {
359+
javaLauncher = javaToolchains.launcherFor {
360+
languageVersion = JavaLanguageVersion.of(8)
361+
}
362+
363+
description = "Run tests with Java 8"
364+
group = LifecycleBasePlugin.VERIFICATION_GROUP
365+
366+
// Copy inputs from the normal test task
367+
val testTask = tasks.getByName("jvmTest") as KotlinJvmTest
368+
classpath = testTask.classpath
369+
testClassesDirs = testTask.testClassesDirs
370+
}
371+
tasks.named("check").configure { dependsOn(testWithJava8) }
372+
342373
afterEvaluate {
343374
val buildTasks =
344375
tasks.matching {

core/src/androidMain/kotlin/com/powersync/DatabaseDriverFactory.android.kt

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -42,38 +42,38 @@ public actual class DatabaseDriverFactory(
4242
PsSqlDriver(
4343
scope = scope,
4444
driver =
45-
AndroidSqliteDriver(
46-
context = context,
47-
schema = schema,
48-
name = dbFilename,
49-
factory =
50-
RequerySQLiteOpenHelperFactory(
51-
listOf(
52-
RequerySQLiteOpenHelperFactory.ConfigurationOptions { config ->
53-
config.customExtensions.add(
54-
SQLiteCustomExtension(
55-
"libpowersync",
56-
"sqlite3_powersync_init",
57-
),
58-
)
59-
config.customExtensions.add(
60-
SQLiteCustomExtension(
61-
"libpowersync-sqlite",
62-
"powersync_init",
63-
),
64-
)
65-
config
45+
AndroidSqliteDriver(
46+
context = context,
47+
schema = schema,
48+
name = dbFilename,
49+
factory =
50+
RequerySQLiteOpenHelperFactory(
51+
listOf(
52+
RequerySQLiteOpenHelperFactory.ConfigurationOptions { config ->
53+
config.customExtensions.add(
54+
SQLiteCustomExtension(
55+
"libpowersync",
56+
"sqlite3_powersync_init",
57+
),
58+
)
59+
config.customExtensions.add(
60+
SQLiteCustomExtension(
61+
"libpowersync-sqlite",
62+
"powersync_init",
63+
),
64+
)
65+
config
66+
},
67+
),
68+
),
69+
callback =
70+
object : AndroidSqliteDriver.Callback(schema) {
71+
override fun onConfigure(db: SupportSQLiteDatabase) {
72+
db.enableWriteAheadLogging()
73+
super.onConfigure(db)
74+
}
6675
},
67-
),
6876
),
69-
callback =
70-
object : AndroidSqliteDriver.Callback(schema) {
71-
override fun onConfigure(db: SupportSQLiteDatabase) {
72-
db.enableWriteAheadLogging()
73-
super.onConfigure(db)
74-
}
75-
},
76-
),
7777
)
7878
setupSqliteBinding()
7979
return this.driver as PsSqlDriver

core/src/commonMain/kotlin/com/powersync/sync/SyncStatus.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ internal data class SyncStatusDataContainer(
8181
get() = downloadError ?: uploadError
8282
}
8383

84+
@ConsistentCopyVisibility
8485
public data class SyncStatus internal constructor(
8586
private var data: SyncStatusDataContainer = SyncStatusDataContainer(),
8687
) : SyncStatusData {

core/src/iosMain/kotlin/com/powersync/DatabaseDriverFactory.ios.kt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,27 +75,27 @@ public actual class DatabaseDriverFactory {
7575
PsSqlDriver(
7676
scope = scope,
7777
driver =
78-
NativeSqliteDriver(
79-
configuration =
80-
DatabaseConfiguration(
81-
name = dbFilename,
82-
version = schema.version.toInt(),
83-
create = { connection -> wrapConnection(connection) { schema.create(it) } },
84-
loggingConfig = Logging(logger = sqlLogger),
85-
lifecycleConfig =
86-
DatabaseConfiguration.Lifecycle(
87-
onCreateConnection = { connection ->
88-
setupSqliteBinding(connection)
89-
wrapConnection(connection) { driver ->
90-
schema.create(driver)
91-
}
92-
},
93-
onCloseConnection = { connection ->
94-
deregisterSqliteBinding(connection)
95-
},
96-
),
78+
NativeSqliteDriver(
79+
configuration =
80+
DatabaseConfiguration(
81+
name = dbFilename,
82+
version = schema.version.toInt(),
83+
create = { connection -> wrapConnection(connection) { schema.create(it) } },
84+
loggingConfig = Logging(logger = sqlLogger),
85+
lifecycleConfig =
86+
DatabaseConfiguration.Lifecycle(
87+
onCreateConnection = { connection ->
88+
setupSqliteBinding(connection)
89+
wrapConnection(connection) { driver ->
90+
schema.create(driver)
91+
}
92+
},
93+
onCloseConnection = { connection ->
94+
deregisterSqliteBinding(connection)
95+
},
96+
),
97+
),
9798
),
98-
),
9999
)
100100
return this.driver as PsSqlDriver
101101
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ development=true
1717
RELEASE_SIGNING_ENABLED=true
1818
# Library config
1919
GROUP=com.powersync
20-
LIBRARY_VERSION=1.0.0-BETA24
20+
LIBRARY_VERSION=1.0.0-BETA25
2121
GITHUB_REPO=https://github.com/powersync-ja/powersync-kotlin.git
2222
# POM
2323
POM_URL=https://github.com/powersync-ja/powersync-kotlin/

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ java = "17"
88
idea = "222.4459.24" # Flamingo | 2022.2.1 (see https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html)
99

1010
# Dependencies
11-
kermit = "2.0.4"
11+
kermit = "2.0.5"
1212
kotlin = "2.0.20"
1313
coroutines = "1.8.1"
1414
kotlinx-datetime = "0.5.0"
@@ -20,7 +20,7 @@ sqlite-android = "3.45.0"
2020
sqlite-jdbc = "3.45.2.0"
2121

2222
sqlDelight = "2.0.2"
23-
stately = "2.0.7"
23+
stately = "2.1.0"
2424
supabase = "3.0.1"
2525
junit = "4.13.2"
2626

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)