1- import com.android.build.gradle.internal.tasks.factory.dependsOn
21import com.powersync.plugins.sonatype.setupGithubRepository
32import de.undercouch.gradle.tasks.download.Download
43import org.gradle.internal.os.OperatingSystem
@@ -22,63 +21,6 @@ plugins {
2221 alias(libs.plugins.kotlin.atomicfu)
2322}
2423
25- val sqliteVersion = " 3450200"
26- val sqliteReleaseYear = " 2024"
27-
28- val sqliteSrcFolder =
29- project.layout.buildDirectory
30- .dir(" native/sqlite" )
31- .get()
32-
33- val downloadSQLiteSources by tasks.registering(Download ::class ) {
34- val zipFileName = " sqlite-amalgamation-$sqliteVersion .zip"
35- val destination = sqliteSrcFolder.file(zipFileName).asFile
36- src(" https://www.sqlite.org/$sqliteReleaseYear /$zipFileName " )
37- dest(destination)
38- onlyIfNewer(true )
39- overwrite(false )
40- }
41-
42- val unzipSQLiteSources by tasks.registering(Copy ::class ) {
43- dependsOn(downloadSQLiteSources)
44-
45- from(
46- zipTree(downloadSQLiteSources.get().dest).matching {
47- include(" */sqlite3.*" )
48- exclude {
49- it.isDirectory
50- }
51- eachFile {
52- this .path = this .name
53- }
54- },
55- )
56- into(sqliteSrcFolder)
57- }
58-
59- val buildCInteropDef by tasks.registering {
60- dependsOn(unzipSQLiteSources)
61-
62- val interopFolder =
63- project.layout.buildDirectory
64- .dir(" interop/sqlite" )
65- .get()
66-
67- val cFile = sqliteSrcFolder.file(" sqlite3.c" ).asFile
68- val defFile = interopFolder.file(" sqlite3.def" ).asFile
69-
70- doFirst {
71- defFile.writeText(
72- """
73- package = com.powersync.sqlite3
74- ---
75-
76- """ .trimIndent() + cFile.readText(),
77- )
78- }
79- outputs.files(defFile)
80- }
81-
8224val binariesFolder = project.layout.buildDirectory.dir(" binaries/desktop" )
8325val downloadPowersyncDesktopBinaries by tasks.registering(Download ::class ) {
8426 description = " Download PowerSync core extensions for JVM builds and releases"
@@ -233,27 +175,11 @@ kotlin {
233175 compileTaskProvider {
234176 compilerOptions.freeCompilerArgs.add(" -Xexport-kdoc" )
235177 }
236-
237- cinterops.create(" sqlite" ) {
238- val cInteropTask = tasks[interopProcessingTaskName]
239- cInteropTask.dependsOn(buildCInteropDef)
240- definitionFile =
241- buildCInteropDef
242- .get()
243- .outputs.files.singleFile
244- compilerOpts.addAll(
245- listOf (
246- " -DHAVE_GETHOSTUUID=0" ,
247- " -DSQLITE_ENABLE_LOAD_EXTENSION=1" ,
248- " -DSQLITE_ENABLE_FTS5" ,
249- ),
250- )
251- }
252178 }
253179
254180 if (konanTarget.family == Family .IOS && konanTarget.name.contains(" simulator" )) {
255181 binaries.withType<TestExecutable >().configureEach {
256- linkTaskProvider.dependsOn(unzipPowersyncFramework)
182+ linkTaskProvider.configure { dependsOn(unzipPowersyncFramework) }
257183 linkerOpts(" -framework" , " powersync-sqlite-core" )
258184 val frameworkRoot =
259185 binariesFolder
@@ -310,7 +236,7 @@ kotlin {
310236 implementation(libs.kotlinx.datetime)
311237 implementation(libs.stately.concurrency)
312238 implementation(libs.configuration.annotations)
313- api(project( " : persistence" ) )
239+ api(projects. persistence)
314240 api(libs.kermit)
315241 }
316242
@@ -378,17 +304,6 @@ android {
378304 .get()
379305 .toInt()
380306 consumerProguardFiles(" proguard-rules.pro" )
381-
382- @Suppress(" UnstableApiUsage" )
383- externalNativeBuild {
384- cmake {
385- arguments.addAll(
386- listOf (
387- " -DSQLITE3_SRC_DIR=${sqliteSrcFolder.asFile.absolutePath} " ,
388- ),
389- )
390- }
391- }
392307 }
393308
394309 sourceSets {
@@ -428,27 +343,4 @@ val testWithJava8 by tasks.registering(KotlinJvmTest::class) {
428343}
429344tasks.named(" check" ).configure { dependsOn(testWithJava8) }
430345
431- afterEvaluate {
432- val buildTasks =
433- tasks.matching {
434- val taskName = it.name
435- if (taskName.contains(" Clean" )) {
436- return @matching false
437- }
438- if (taskName.contains(" externalNative" ) ||
439- taskName.contains(" CMake" ) ||
440- taskName.contains(
441- " generateJsonModel" ,
442- )
443- ) {
444- return @matching true
445- }
446- return @matching false
447- }
448-
449- buildTasks.forEach {
450- it.dependsOn(buildCInteropDef)
451- }
452- }
453-
454346setupGithubRepository()
0 commit comments