Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
matrix:
include:
- os: macos-latest
targets: iosSimulatorArm64Test jvmTest lintKotlin
targets: iosSimulatorArm64Test macosArm64Test jvmTest
- os: ubuntu-latest
targets: testDebugUnitTest testReleaseUnitTest jvmTest
targets: testDebugUnitTest testReleaseUnitTest jvmTest lintKotlin
- os: windows-latest
targets: jvmTest
runs-on: ${{ matrix.os }}
Expand Down
22 changes: 22 additions & 0 deletions PowerSyncKotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ kotlin {
iosX64(),
iosArm64(),
iosSimulatorArm64(),
macosArm64(),
macosX64(),
).forEach {
it.binaries.framework {
export(project(":core"))
Expand All @@ -41,6 +43,26 @@ kotlin {
}
}

repositories {
maven {
name = "PowerSyncSQLiterFork"
url = uri("https://powersync-ja.github.io/SQLiter")
content {
includeModuleByRegex("co.touchlab", "sqliter-driver.*")
}
}
}

configurations.all {
resolutionStrategy {
// This version has not been released yet (https://github.com/touchlab/SQLiter/pull/124), so we're pointing this
// towards our fork with the repositories block above.
// The API is identical, but we have to make sure this particular project builds the xcframework with the
// patched SQLiter version to avoid linker errors on macOS.
force("co.touchlab:sqliter-driver:1.3.2-powersync")
}
}

kmmbridge {
artifactManager.set(SonatypePortalPublishArtifactManager(project, repositoryName = null))
artifactManager.finalizeValue()
Expand Down
11 changes: 2 additions & 9 deletions compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.powersync.plugins.sonatype.setupGithubRepository
import com.powersync.plugins.utils.powersyncTargets

plugins {
alias(libs.plugins.kotlinMultiplatform)
Expand All @@ -10,15 +11,7 @@ plugins {
}

kotlin {
androidTarget {
publishLibraryVariants("release", "debug")
}

jvm()

iosX64()
iosArm64()
iosSimulatorArm64()
powersyncTargets(includeTargetsWithoutComposeSupport = false)

explicitApi()

Expand Down
12 changes: 2 additions & 10 deletions connectors/supabase/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.powersync.plugins.sonatype.setupGithubRepository
import com.powersync.plugins.utils.powersyncTargets
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

plugins {
Expand All @@ -10,12 +11,7 @@ plugins {
}

kotlin {
androidTarget {
publishLibraryVariants("release", "debug")
}

jvm()

powersyncTargets()
targets.withType<KotlinNativeTarget> {
compilations.named("main") {
compileTaskProvider {
Expand All @@ -24,10 +20,6 @@ kotlin {
}
}

iosX64()
iosArm64()
iosSimulatorArm64()

explicitApi()

sourceSets {
Expand Down
69 changes: 35 additions & 34 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import com.powersync.plugins.sonatype.setupGithubRepository
import com.powersync.plugins.utils.powersyncTargets
import de.undercouch.gradle.tasks.download.Download
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.internal.os.OperatingSystem
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.TestExecutable
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
Expand Down Expand Up @@ -84,15 +83,22 @@ val downloadPowersyncFramework by tasks.registering(Download::class) {
onlyIfModified(true)
}

val unzipPowersyncFramework by tasks.registering(Copy::class) {
val unzipPowersyncFramework by tasks.registering(Exec::class) {
dependsOn(downloadPowersyncFramework)

from(
zipTree(downloadPowersyncFramework.get().dest).matching {
include("powersync-sqlite-core.xcframework/**")
},
)
into(binariesFolder.map { it.dir("framework") })
val zipfile = downloadPowersyncFramework.get().dest
inputs.file(zipfile)
val destination = File(zipfile.parentFile, "extracted")
doFirst {
destination.deleteRecursively()
destination.mkdir()
}

// We're using unzip here because the Gradle copy task doesn't support symlinks.
executable = "unzip"
args(zipfile.absolutePath)
workingDir(destination)
outputs.dir(destination)
}

val sqliteJDBCFolder =
Expand Down Expand Up @@ -150,26 +156,7 @@ val moveJDBCJNIFiles by tasks.registering(Copy::class) {
}

kotlin {
androidTarget {
publishLibraryVariants("release", "debug")

@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}
jvm {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
// https://jakewharton.com/kotlins-jdk-release-compatibility-flag/
freeCompilerArgs.add("-Xjdk-release=8")
}
}

iosX64()
iosArm64()
iosSimulatorArm64()
powersyncTargets()

targets.withType<KotlinNativeTarget> {
compilations.named("main") {
Expand All @@ -184,7 +171,20 @@ kotlin {
linkerOpts("-framework", "powersync-sqlite-core")
val frameworkRoot =
binariesFolder
.map { it.dir("framework/powersync-sqlite-core.xcframework/ios-arm64_x86_64-simulator") }
.map { it.dir("framework/extracted/powersync-sqlite-core.xcframework/ios-arm64_x86_64-simulator") }
.get()
.asFile.path

linkerOpts("-F", frameworkRoot)
linkerOpts("-rpath", frameworkRoot)
}
} else if (konanTarget.family == Family.OSX) {
binaries.withType<TestExecutable>().configureEach {
linkTaskProvider.configure { dependsOn(unzipPowersyncFramework) }
linkerOpts("-framework", "powersync-sqlite-core")
var frameworkRoot =
binariesFolder
.map { it.dir("framework/extracted/powersync-sqlite-core.xcframework/macos-arm64_x86_64") }
.get()
.asFile.path

Expand Down Expand Up @@ -253,8 +253,8 @@ kotlin {
}
}

iosMain.dependencies {
implementation(libs.ktor.client.ios)
appleMain.dependencies {
implementation(libs.ktor.client.darwin)
}

commonTest.dependencies {
Expand All @@ -271,8 +271,9 @@ kotlin {
// tests.
jvmTest.get().dependsOn(commonIntegrationTest)

// We're linking the xcframework for the simulator tests, so they can use integration tests too
iosSimulatorArm64Test.orNull?.dependsOn(commonIntegrationTest)
// We have special setup in this build configuration to make these tests link the PowerSync extension, so they
// can run integration tests along with the executable for unit testing.
appleTest.orNull?.dependsOn(commonIntegrationTest)
}
}

Expand Down
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ kermit = { module = "co.touchlab:kermit", version.ref = "kermit" }
kermit-test = { module = "co.touchlab:kermit-test", version.ref = "kermit" }
powersync-sqlite-core-android = { module = "co.powersync:powersync-sqlite-core", version.ref = "powersync-core" }
mavenPublishPlugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "maven-publish" }
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }

test-junit = { group = "junit", name = "junit", version.ref = "junit" }
test-android-runner = { module = "androidx.test:runner", version.ref = "androidx-test-runner" }
Expand All @@ -76,7 +77,7 @@ kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.
uuid = { module = "com.benasher44:uuid", version.ref = "uuid" }

ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-ios = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" }
ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" }
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
ktor-client-contentnegotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" }
Expand Down
25 changes: 3 additions & 22 deletions persistence/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.powersync.plugins.sonatype.setupGithubRepository
import com.powersync.plugins.utils.powersyncTargets
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

Expand All @@ -11,27 +12,7 @@ plugins {
}

kotlin {
androidTarget {
publishLibraryVariants("release", "debug")

@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}

jvm {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
// https://jakewharton.com/kotlins-jdk-release-compatibility-flag/
freeCompilerArgs.add("-Xjdk-release=8")
}
}

iosX64()
iosArm64()
iosSimulatorArm64()
powersyncTargets()

explicitApi()

Expand All @@ -49,7 +30,7 @@ kotlin {
api(libs.sqldelight.driver.jdbc)
}

iosMain.dependencies {
appleMain.dependencies {
api(libs.sqldelight.driver.native)
api(projects.staticSqliteDriver)
}
Expand Down
1 change: 1 addition & 0 deletions plugins/sonatype/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ kotlin {

dependencies {
implementation(libs.mavenPublishPlugin)
implementation(libs.kotlin.gradle.plugin)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.powersync.plugins.utils

import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinTargetContainerWithPresetFunctions

public fun KotlinTargetContainerWithPresetFunctions.powersyncTargets(
native: Boolean = true,
jvm: Boolean = true,
includeTargetsWithoutComposeSupport: Boolean = true,
) {
if (jvm) {
androidTarget {
publishLibraryVariants("release", "debug")

@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}

jvm {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
// https://jakewharton.com/kotlins-jdk-release-compatibility-flag/
freeCompilerArgs.add("-Xjdk-release=8")
}
}
}

if (native) {
iosX64()
iosArm64()
iosSimulatorArm64()

if (includeTargetsWithoutComposeSupport) {
macosX64()
macosArm64()
}
}
}
8 changes: 5 additions & 3 deletions static-sqlite-driver/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import java.io.File
import java.io.FileInputStream
import com.powersync.plugins.sonatype.setupGithubRepository
import com.powersync.plugins.utils.powersyncTargets
import de.undercouch.gradle.tasks.download.Download
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.utils.NativeCompilerDownloader
Expand Down Expand Up @@ -75,6 +76,8 @@ fun compileSqlite(target: KotlinNativeTarget): TaskProvider<Task> {
KonanTarget.IOS_X64 -> "x86_64-apple-ios12.0-simulator" to "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
KonanTarget.IOS_ARM64 -> "arm64-apple-ios12.0" to "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"
KonanTarget.IOS_SIMULATOR_ARM64 -> "arm64-apple-ios14.0-simulator" to "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
KonanTarget.MACOS_ARM64 -> "aarch64-apple-macos" to "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/"
KonanTarget.MACOS_X64 -> "x86_64-apple-macos" to "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/"
else -> error("Unexpected target $target")
}

Expand Down Expand Up @@ -149,9 +152,8 @@ fun compileSqlite(target: KotlinNativeTarget): TaskProvider<Task> {
}

kotlin {
iosX64()
iosArm64()
iosSimulatorArm64()
// We use sqlite3-jdbc on JVM platforms instead
powersyncTargets(jvm=false)

applyDefaultHierarchyTemplate()
explicitApi()
Expand Down