Move Kotlin shared code

This commit is contained in:
James Babcock committed 2026-09-18 20:43:24 -07:00
1 parent 1e1c3f799d
commit c0f8f7e9c2
2 files changed
+19 -1

No files matched your search

+18
View File
@@ -255,6 +255,10 @@ def faceclawVersionCode = {
return parts[0] * 10000 + parts[1] * 100 + parts[2]
}()
// ios-port packages commonMain in an AAR. Keeping this conditional lets the
// source relocation merge there without compiling the shared classes twice.
def faceclawDependencies = new groovy.json.JsonSlurper().parse(file("$rootDir/../../package.json")).dependencies ?: [:]
android {
compileSdkVersion 35
buildToolsVersion "35"
@@ -262,6 +266,11 @@ android {
sourceSets.main {
jniLibs.srcDirs += ["$projectDir/src/main/jniLibs"]
// Keep portable Kotlin at the same path as ios-port's KMP commonMain.
// main compiles it directly with the existing Android Kotlin plugin.
if (!faceclawDependencies.containsKey("@faceclaw/kotlin")) {
java.srcDirs += ["$rootDir/../../native/kotlin/shared/src/commonMain/kotlin"]
}
}
defaultConfig {
@@ -288,6 +297,15 @@ android {
}
}
// NativeScript can retain deleted App_Resources sources in its generated
// project. Remove the former copy before Kotlin compilation after this move.
def removeLegacyKotlinBridgeSource = tasks.register("removeLegacyKotlinBridgeSource", Delete) {
delete file("$projectDir/src/main/java/com/faceclaw/shared/KotlinBridge.kt")
}
tasks.matching { it.name.startsWith("compile") && it.name.endsWith("Kotlin") }.configureEach {
dependsOn removeLegacyKotlinBridgeSource
}
tasks.matching { it.name == "preBuild" }.configureEach {
dependsOn tasks.named("prepareFaceclawNativeLibs")
dependsOn tasks.named("prepareFaceclawLlama")
@@ -6,7 +6,7 @@ interface KotlinBridgeListener {
}
/**
* First step toward commonMain: only portable Kotlin, with no Android/JVM APIs.
* Portable Kotlin at the same commonMain source path used by ios-port.
* Calls and callbacks are synchronous on the caller's thread. The listener is
* used only during roundTrip and is never retained.
*/