1
1
import com.powersync.plugins.sonatype.setupGithubRepository
2
+ import com.powersync.plugins.utils.powersyncTargets
2
3
import de.undercouch.gradle.tasks.download.Download
3
4
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
4
5
import org.gradle.internal.os.OperatingSystem
5
- import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
6
- import org.jetbrains.kotlin.gradle.dsl.JvmTarget
7
6
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
8
7
import org.jetbrains.kotlin.gradle.plugin.mpp.TestExecutable
9
8
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
@@ -84,15 +83,22 @@ val downloadPowersyncFramework by tasks.registering(Download::class) {
84
83
onlyIfModified(true )
85
84
}
86
85
87
- val unzipPowersyncFramework by tasks.registering(Copy ::class ) {
86
+ val unzipPowersyncFramework by tasks.registering(Exec ::class ) {
88
87
dependsOn(downloadPowersyncFramework)
89
88
90
- from(
91
- zipTree(downloadPowersyncFramework.get().dest).matching {
92
- include(" powersync-sqlite-core.xcframework/**" )
93
- },
94
- )
95
- into(binariesFolder.map { it.dir(" framework" ) })
89
+ val zipfile = downloadPowersyncFramework.get().dest
90
+ inputs.file(zipfile)
91
+ val destination = File (zipfile.parentFile, " extracted" )
92
+ doFirst {
93
+ destination.deleteRecursively()
94
+ destination.mkdir()
95
+ }
96
+
97
+ // We're using unzip here because the Gradle copy task doesn't support symlinks.
98
+ executable = " unzip"
99
+ args(zipfile.absolutePath)
100
+ workingDir(destination)
101
+ outputs.dir(destination)
96
102
}
97
103
98
104
val sqliteJDBCFolder =
@@ -150,26 +156,7 @@ val moveJDBCJNIFiles by tasks.registering(Copy::class) {
150
156
}
151
157
152
158
kotlin {
153
- androidTarget {
154
- publishLibraryVariants(" release" , " debug" )
155
-
156
- @OptIn(ExperimentalKotlinGradlePluginApi ::class )
157
- compilerOptions {
158
- jvmTarget.set(JvmTarget .JVM_17 )
159
- }
160
- }
161
- jvm {
162
- @OptIn(ExperimentalKotlinGradlePluginApi ::class )
163
- compilerOptions {
164
- jvmTarget.set(JvmTarget .JVM_1_8 )
165
- // https://jakewharton.com/kotlins-jdk-release-compatibility-flag/
166
- freeCompilerArgs.add(" -Xjdk-release=8" )
167
- }
168
- }
169
-
170
- iosX64()
171
- iosArm64()
172
- iosSimulatorArm64()
159
+ powersyncTargets()
173
160
174
161
targets.withType<KotlinNativeTarget > {
175
162
compilations.named(" main" ) {
@@ -184,7 +171,20 @@ kotlin {
184
171
linkerOpts(" -framework" , " powersync-sqlite-core" )
185
172
val frameworkRoot =
186
173
binariesFolder
187
- .map { it.dir(" framework/powersync-sqlite-core.xcframework/ios-arm64_x86_64-simulator" ) }
174
+ .map { it.dir(" framework/extracted/powersync-sqlite-core.xcframework/ios-arm64_x86_64-simulator" ) }
175
+ .get()
176
+ .asFile.path
177
+
178
+ linkerOpts(" -F" , frameworkRoot)
179
+ linkerOpts(" -rpath" , frameworkRoot)
180
+ }
181
+ } else if (konanTarget.family == Family .OSX ) {
182
+ binaries.withType<TestExecutable >().configureEach {
183
+ linkTaskProvider.configure { dependsOn(unzipPowersyncFramework) }
184
+ linkerOpts(" -framework" , " powersync-sqlite-core" )
185
+ var frameworkRoot =
186
+ binariesFolder
187
+ .map { it.dir(" framework/extracted/powersync-sqlite-core.xcframework/macos-arm64_x86_64" ) }
188
188
.get()
189
189
.asFile.path
190
190
@@ -253,8 +253,8 @@ kotlin {
253
253
}
254
254
}
255
255
256
- iosMain .dependencies {
257
- implementation(libs.ktor.client.ios )
256
+ appleMain .dependencies {
257
+ implementation(libs.ktor.client.darwin )
258
258
}
259
259
260
260
commonTest.dependencies {
@@ -271,8 +271,9 @@ kotlin {
271
271
// tests.
272
272
jvmTest.get().dependsOn(commonIntegrationTest)
273
273
274
- // We're linking the xcframework for the simulator tests, so they can use integration tests too
275
- iosSimulatorArm64Test.orNull?.dependsOn(commonIntegrationTest)
274
+ // We have special setup in this build configuration to make these tests link the PowerSync extension, so they
275
+ // can run integration tests along with the executable for unit testing.
276
+ appleTest.orNull?.dependsOn(commonIntegrationTest)
276
277
}
277
278
}
278
279
0 commit comments