Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit 42cd8fc

Browse files
committed
ios tasks
1 parent e33eba3 commit 42cd8fc

File tree

5 files changed

+76
-12
lines changed

5 files changed

+76
-12
lines changed
Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package org.asyncstorage.sqlite.plugin
22

3-
import org.asyncstorage.sqlite.plugin.tasks.SqliteStorageAndroidBundle
43
import org.asyncstorage.sqlite.plugin.extensions.BundleExtension
4+
import org.asyncstorage.sqlite.plugin.tasks.SqliteStorageAndroidBundleTask
5+
import org.asyncstorage.sqlite.plugin.tasks.SqliteStorageIosBundleTask
56
import org.gradle.api.Project
67
import org.gradle.api.tasks.TaskProvider
78
import org.gradle.kotlin.dsl.register
@@ -11,29 +12,49 @@ private const val BUNDLE_TASK_NAME = "bundleSqliteStorage"
1112

1213
fun Project.configureBundle(bundleConfig: BundleExtension) {
1314
val androidBundle = configureAndroidBundle(bundleConfig)
15+
val iosBundle = configureIosBundle(bundleConfig)
1416

1517

1618
tasks.register(BUNDLE_TASK_NAME) {
1719
group = PLUGIN_GROUP
1820
description = "Builds final binaries for supported platforms"
1921
dependsOn(androidBundle)
22+
dependsOn(iosBundle)
2023
}
2124
}
2225

2326

24-
private fun Project.configureAndroidBundle(bundleConfig: BundleExtension): TaskProvider<SqliteStorageAndroidBundle> {
25-
val androidBundle = tasks.register<SqliteStorageAndroidBundle>("${BUNDLE_TASK_NAME}Android") {
27+
private fun Project.configureIosBundle(bundleConfig: BundleExtension): TaskProvider<SqliteStorageIosBundleTask> {
28+
val iosBundleTask = tasks.register<SqliteStorageIosBundleTask>("${BUNDLE_TASK_NAME}Ios") {
2629
outputDir.set(bundleConfig.outputDir)
27-
outputAarName.set(bundleConfig.androidAarName)
28-
sourceAarLocation.set(project.layout.buildDirectory.file("outputs/aar/sqlite-storage-release.aar"))
30+
outputFrameworkName.set(bundleConfig.binaryName)
31+
sourceFramework.set(project.layout.buildDirectory.dir("XCFrameworks/release/SqliteStorage.xcframework"))
2932
}
33+
34+
afterEvaluate {
35+
iosBundleTask.configure {
36+
dependsOn(tasks.named("assembleSqliteStorageReleaseXCFramework"))
37+
}
38+
}
39+
40+
return iosBundleTask
41+
}
42+
43+
44+
private fun Project.configureAndroidBundle(bundleConfig: BundleExtension): TaskProvider<SqliteStorageAndroidBundleTask> {
45+
val androidBundleTask =
46+
tasks.register<SqliteStorageAndroidBundleTask>("${BUNDLE_TASK_NAME}Android") {
47+
outputDir.set(bundleConfig.outputDir)
48+
outputAarName.set(bundleConfig.binaryName)
49+
sourceAar.set(project.layout.buildDirectory.file("outputs/aar/sqlite-storage-release.aar"))
50+
}
3051
afterEvaluate {
31-
androidBundle.configure {
52+
androidBundleTask.configure {
3253
dependsOn(tasks.named("bundleReleaseAar"))
3354
}
3455
}
3556

36-
return androidBundle
57+
return androidBundleTask
3758
}
3859

3960

sqlite-storage-plugin/src/main/kotlin/extensions/BundleExtension.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ abstract class BundleExtension(@Inject private val project: Project) {
99
val outputDir: DirectoryProperty = project.objects.directoryProperty()
1010

1111

12-
val androidAarName: Property<String> = project.objects.property(String::class.java)
12+
val binaryName: Property<String> = project.objects.property(String::class.java)
1313
}

sqlite-storage-plugin/src/main/kotlin/tasks/AndroidBundleTask.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import org.gradle.api.tasks.InputFile
1010
import org.gradle.api.tasks.OutputDirectory
1111
import org.gradle.api.tasks.TaskAction
1212

13-
internal abstract class SqliteStorageAndroidBundle : DefaultTask() {
13+
internal abstract class SqliteStorageAndroidBundleTask : DefaultTask() {
1414
override fun getGroup() = PLUGIN_GROUP
1515

1616
override fun getDescription() = "Bundles release AAR and moves it to release directory"
@@ -22,11 +22,11 @@ internal abstract class SqliteStorageAndroidBundle : DefaultTask() {
2222
abstract val outputAarName: Property<String>
2323

2424
@get:InputFile
25-
abstract val sourceAarLocation: RegularFileProperty
25+
abstract val sourceAar: RegularFileProperty
2626

2727
@TaskAction
2828
fun execute() {
29-
val aar = sourceAarLocation.get().asFile
29+
val aar = sourceAar.get().asFile
3030
if (!aar.exists()) {
3131
throw IllegalStateException("AAR file not built")
3232
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.asyncstorage.sqlite.plugin.tasks
2+
3+
import org.asyncstorage.sqlite.plugin.PLUGIN_GROUP
4+
import org.gradle.api.DefaultTask
5+
import org.gradle.api.file.DirectoryProperty
6+
import org.gradle.api.provider.Property
7+
import org.gradle.api.tasks.Input
8+
import org.gradle.api.tasks.InputDirectory
9+
import org.gradle.api.tasks.OutputDirectory
10+
import org.gradle.api.tasks.TaskAction
11+
12+
internal abstract class SqliteStorageIosBundleTask : DefaultTask() {
13+
override fun getGroup() = PLUGIN_GROUP
14+
15+
override fun getDescription() = "Bundles release XCFramework and moves it to release directory"
16+
17+
@get:OutputDirectory
18+
abstract val outputDir: DirectoryProperty
19+
20+
@get:Input
21+
abstract val outputFrameworkName: Property<String>
22+
23+
@get:InputDirectory
24+
abstract val sourceFramework: DirectoryProperty
25+
26+
@TaskAction
27+
fun execute() {
28+
val framework = sourceFramework.get().asFile
29+
if (!framework.exists()) {
30+
throw IllegalStateException("XCFramework not found at location ${framework.absolutePath}")
31+
}
32+
val finalName: String = outputFrameworkName.get().let { name ->
33+
if (name.endsWith(".xcframework")) name
34+
else "${name}.xcframework"
35+
}
36+
37+
38+
framework.copyRecursively(
39+
target = outputDir.file(finalName).get().asFile,
40+
overwrite = true
41+
)
42+
}
43+
}

sqlite-storage/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ sqldelight {
6868

6969
asyncStorage {
7070
outputDir.set(rootProject.file("nativeLib"))
71-
androidAarName.set("sqlite-storage-android.aar")
71+
binaryName.set("sqlite-storage")
7272
}
7373

7474
android {

0 commit comments

Comments
 (0)