Skip to content

Commit e7284f9

Browse files
committed
Simplify unzipping
1 parent 428f5e3 commit e7284f9

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

demos/supabase-todolist/gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
kotlin.code.style=official
22
xcodeproj=./iosApp
33
android.useAndroidX=true
4+
org.gradle.caching=true
45
org.gradle.jvmargs=-Xmx3g
56
org.jetbrains.compose.experimental.jscanvas.enabled=true
67
org.jetbrains.compose.experimental.macos.enabled=true

plugins/build-plugin/src/main/kotlin/com/powersync/compile/UnzipSqlite.kt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,33 @@ package com.powersync.compile
22

33
import org.gradle.api.file.Directory
44
import org.gradle.api.file.DirectoryProperty
5+
import org.gradle.api.file.FileTree
56
import org.gradle.api.provider.Provider
67
import org.gradle.api.tasks.CacheableTask
78
import org.gradle.api.tasks.Copy
89
import org.gradle.api.tasks.OutputDirectory
910

1011
/**
11-
* A cacheable [Copy] task providing typed providers for the emitted [sqlite3C] and [sqlite3H]
12-
* files, making them easier to access in other tasks.
12+
* A cacheable [Copy] task providing a typed provider for the output directory.
1313
*/
1414
@CacheableTask
1515
abstract class UnzipSqlite: Copy() {
1616
@get:OutputDirectory
1717
abstract val destination: DirectoryProperty
1818

19-
fun intoDirectory(dir: Provider<Directory>) {
19+
fun unzipSqlite(src: FileTree, dir: Provider<Directory>) {
20+
from(
21+
src.matching {
22+
include("*/sqlite3.*")
23+
exclude {
24+
it.isDirectory
25+
}
26+
eachFile {
27+
this.path = this.name
28+
}
29+
},
30+
)
31+
2032
into(dir)
2133
destination.set(dir)
2234
}

static-sqlite-driver/build.gradle.kts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,13 @@ val downloadSQLiteSources by tasks.registering(Download::class) {
2828
}
2929

3030
val unzipSQLiteSources by tasks.registering(UnzipSqlite::class) {
31-
from(
32-
zipTree(downloadSQLiteSources.map { it.outputs.files.singleFile }).matching {
33-
include("*/sqlite3.*")
34-
exclude {
35-
it.isDirectory
36-
}
37-
eachFile {
38-
this.path = this.name
39-
}
40-
},
31+
val zip = downloadSQLiteSources.map { it.outputs.files.singleFile }
32+
inputs.file(zip)
33+
34+
unzipSqlite(
35+
src = zipTree(zip),
36+
dir = layout.buildDirectory.dir("downloads/sqlite3")
4137
)
42-
intoDirectory(layout.buildDirectory.dir("downloads/sqlite3"))
4338
}
4439

4540
// Obtain host and platform manager from Kotlin multiplatform plugin. They're supposed to be

0 commit comments

Comments
 (0)