Skip to content

Commit df2b75e

Browse files
committed
Bring back desktop support
1 parent e31325f commit df2b75e

File tree

9 files changed

+55
-29
lines changed

9 files changed

+55
-29
lines changed

compose/build.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ plugins {
1212
}
1313

1414
kotlin {
15-
powersyncTargets(includeTargetsWithoutComposeSupport = false)
15+
powersyncTargets(
16+
includeTargetsWithoutComposeSupport = false,
17+
// Recent versions of Compose Multiplatform generate bytecode with Java 11, which we have
18+
// to adopt as well
19+
legacyJavaSupport = false,
20+
)
1621

1722
explicitApi()
1823

demos/android-supabase-todolist/build.gradle.kts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,21 @@ kotlin {
8686
}
8787

8888
val useReleasedVersions = getLocalProperty("USE_RELEASED_POWERSYNC_VERSIONS", "false") == "true"
89-
if (!useReleasedVersions) {
89+
if (useReleasedVersions) {
9090
configurations.all {
9191
// https://docs.gradle.org/current/userguide/resolution_rules.html#sec:conditional-dependency-substitution
9292
resolutionStrategy.dependencySubstitution.all {
9393
requested.let {
94-
if (it is ModuleComponentSelector && it.group == "com.powersync") {
95-
val targetProject = findProject(":${it.module}")
96-
if (targetProject != null) {
97-
useTarget(targetProject)
94+
if (it is ProjectComponentSelector) {
95+
val projectPath = it.projectPath
96+
// Translate a dependency of e.g. :core into com.powersync:core:latest.release,
97+
// taking into account that the Supabase connector uses a custom name.
98+
val moduleName = when (projectPath) {
99+
":connectors:supabase" -> "connector-supabase"
100+
else -> it.projectPath.substring(1).replace(':', '-')
98101
}
102+
103+
useTarget("com.powersync:${moduleName}:latest.release")
99104
}
100105
}
101106
}
@@ -120,11 +125,11 @@ dependencies {
120125
androidTestImplementation(libs.androidx.ui.test.junit4)
121126
debugImplementation(libs.androidx.ui.tooling)
122127
debugImplementation(libs.androidx.ui.test.manifest)
123-
// To use a fixed version, replace "latest.release" with the latest version available at
128+
// When adopting the PowerSync dependencies into your project, use the latest version available at
124129
// https://central.sonatype.com/artifact/com.powersync/core
125-
implementation("com.powersync:core:latest.release")
126-
implementation("com.powersync:connector-supabase:latest.release")
127-
implementation("com.powersync:compose:latest.release")
130+
implementation(projects.core) // "com.powersync:core:latest.release"
131+
implementation(projects.connectors.supabase) // "com.powersync:connector-supabase:latest.release"
132+
implementation(projects.compose) // "com.powersync:compose:latest.release"
128133
implementation(libs.uuid)
129134
implementation(libs.kermit)
130135
implementation(libs.androidx.material.icons.extended)

demos/supabase-todolist/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ all items have been received.
4141
1. Clone this repo: ```git clone https://github.com/powersync-ja/powersync-kotlin.git```
4242
2. Open the repo in Android Studio. This creates a `local.properties` file in root and should contain a `sdk.dir=/path/to/android/sdk` line.
4343
3. Sync the project with Gradle (this should happen automatically, or choose File > Sync project with Gradle Files).
44-
4. Open the `demos/supabase-todolist` directory in Android Studio and sync this project with Gradle.
45-
5. Insert your Supabase project URL, Supabase Anon Key, and PowerSync instance URL into the `local.properties` file:
44+
4. Insert your Supabase project URL, Supabase Anon Key, and PowerSync instance URL into the `demos/supabase-todlist/local.properties` file:
4645

4746
```bash
4847
# local.properties

demos/supabase-todolist/androidBackgroundSync/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ android {
4242
}
4343

4444
dependencies {
45-
// When copying this example, replace "latest.release" with the current version available
45+
// When copying this example, use the the current version available
4646
// at: https://central.sonatype.com/artifact/com.powersync/connector-supabase
47-
implementation("com.powersync:connector-supabase:latest.release")
47+
implementation(projects.connectors.supabase) // "com.powersync:connector-supabase"
4848

4949
implementation(projects.demos.supabaseTodolist.shared)
5050

demos/supabase-todolist/build.gradle.kts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,30 @@ if (localPropertiesFile.exists()) {
1313
val useReleasedVersions = localProperties.getProperty("USE_RELEASED_POWERSYNC_VERSIONS", "false") == "true"
1414

1515
subprojects {
16-
if (!useReleasedVersions) {
16+
if (useReleasedVersions) {
1717
configurations.all {
1818
// https://docs.gradle.org/current/userguide/resolution_rules.html#sec:conditional-dependency-substitution
1919
resolutionStrategy.dependencySubstitution.all {
2020
requested.let {
21-
if (it is ModuleComponentSelector && it.group == "com.powersync") {
22-
val targetProject = findProject(":${it.module}")
23-
if (targetProject != null) {
24-
useTarget(targetProject)
21+
if (it is ProjectComponentSelector) {
22+
val projectPath = it.projectPath
23+
if (projectPath.contains("demos")) {
24+
// Project dependency within the demo, don't replace
25+
return@let
2526
}
27+
28+
// Translate a dependency of e.g. :core into com.powersync:core:latest.release,
29+
// taking into account that the Supabase connector uses a custom name.
30+
val moduleName = when (projectPath) {
31+
":connectors:supabase" -> "connector-supabase"
32+
else -> it.projectPath.substring(1).replace(':', '-')
33+
}
34+
35+
useTarget("com.powersync:${moduleName}:latest.release")
2636
}
2737
}
2838
}
2939
}
3040
}
3141
}
42+

demos/supabase-todolist/desktopApp/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ kotlin {
1111
sourceSets {
1212
jvmMain.dependencies {
1313
implementation(compose.desktop.currentOs)
14-
//implementation(projects.shared)
14+
implementation(projects.demos.supabaseTodolist.shared)
1515
}
1616
}
1717
}

demos/supabase-todolist/shared/build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ kotlin {
3939
}
4040
sourceSets {
4141
commonMain.dependencies {
42-
// When copying this example, replace "latest.release" with the current version available
42+
// When copying this example, use the current version available
4343
// at: https://central.sonatype.com/artifact/com.powersync/core
44-
api("com.powersync:core:latest.release")
45-
implementation("com.powersync:connector-supabase:latest.release")
46-
implementation("com.powersync:compose:latest.release")
44+
api(projects.core) // "com.powersync:core"
45+
implementation(projects.connectors.supabase) // "com.powersync:connector-supabase"
46+
implementation(projects.compose) // "com.powersync:compose"
4747
implementation(libs.uuid)
4848
implementation(compose.runtime)
4949
implementation(compose.foundation)

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ stately = "2.1.0"
2828
supabase = "3.2.2"
2929
junit = "4.13.2"
3030

31-
compose = "1.6.11" # This is for the multiplatform compose
31+
compose = "1.8.2" # This is for the multiplatform compose
3232
androidCompose = "2025.07.00"
3333
compose-preview = "1.8.3"
34-
compose-lifecycle = "2.8.4"
34+
compose-lifecycle = "2.9.1"
3535
androidxSqlite = "2.5.2"
3636
androidxSplashscreen = "1.0.1"
3737

plugins/sonatype/src/main/kotlin/com/powersync/plugins/utils/KmpUtils.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public fun KotlinTargetContainerWithPresetFunctions.powersyncTargets(
99
jvm: Boolean = true,
1010
includeTargetsWithoutComposeSupport: Boolean = true,
1111
watchOS: Boolean = true,
12+
legacyJavaSupport: Boolean = true,
1213
) {
1314
if (jvm) {
1415
androidTarget {
@@ -23,9 +24,14 @@ public fun KotlinTargetContainerWithPresetFunctions.powersyncTargets(
2324
jvm {
2425
@OptIn(ExperimentalKotlinGradlePluginApi::class)
2526
compilerOptions {
26-
jvmTarget.set(JvmTarget.JVM_1_8)
27-
// https://jakewharton.com/kotlins-jdk-release-compatibility-flag/
28-
freeCompilerArgs.add("-Xjdk-release=8")
27+
if (legacyJavaSupport) {
28+
jvmTarget.set(JvmTarget.JVM_1_8)
29+
// https://jakewharton.com/kotlins-jdk-release-compatibility-flag/
30+
freeCompilerArgs.add("-Xjdk-release=8")
31+
} else {
32+
jvmTarget.set(JvmTarget.JVM_11)
33+
freeCompilerArgs.add("-Xjdk-release=11")
34+
}
2935
}
3036
}
3137
}

0 commit comments

Comments
 (0)