Add Android KMP library backend alongside legacy AGP integration - #280
Add Android KMP library backend alongside legacy AGP integration#280Milerius wants to merge 1 commit into
Conversation
1ade332 to
24020fe
Compare
|
Sorry for the late reply. I missed the notification 🙇 This looks good to me. My private issue is still tying me down right now, but I think I can merge this in the next (the final) version of 0.3.x. I'll let you know about any updates as soon as possible. Thanks for the contribution again! |
| private fun Project.findAndroidSdkRoot(): File? { | ||
| val sdkFromProperties = rootProject.file("local.properties") | ||
| .takeIf(File::exists) | ||
| ?.inputStream() | ||
| ?.use { input -> | ||
| Properties().apply { load(input) }.getProperty("sdk.dir") | ||
| } | ||
| ?.takeIf(String::isNotBlank) | ||
| ?.let(::File) | ||
| ?.takeIf(File::exists) | ||
| if (sdkFromProperties != null) { | ||
| return sdkFromProperties | ||
| } |
There was a problem hiding this comment.
I've been working on a PR to add AGP v9 support and I think I found cleaner solution for getting these properties:
https://github.com/fegan104/gobley/pull/1/changes#diff-de3c62ac66007a176b7db6b1431bd2d59b83ad6b6d35a6f01dd73b615203ee70R43
There was a problem hiding this comment.
These values are available in KotlinMultiplatformAndroidComponentsExtension so you don't need to rely on local.properties file parsing
There was a problem hiding this comment.
I agree. This should be retrieved via AGP extensions.
| val KotlinTarget.gobleyPlatformType: KotlinPlatformType | ||
| get() = when { | ||
| this is KotlinMultiplatformAndroidTarget -> KotlinPlatformType.androidJvm | ||
| else -> platformType | ||
| } |
There was a problem hiding this comment.
This is due to KotlinTarget.platformType returning KotlinPlatformType.jvm instead of androidJvm, right? Seems like a good workaround, but I think there should be a better name. I want something like kmpAgpSafePlatformType, but this is more verbose than gobleyPlatformType.
There was a problem hiding this comment.
safePlatformName would do? Along with a KDoc with the reason it's needed..
gobley#280) Add KotlinTargetPlatformUtils with gobleyPlatformType/isGobleyAndroidTarget extensions that recognise KotlinMultiplatformAndroidLibraryTarget as androidJvm. CargoPlugin, UniFfiPlugin, and GobleyKotlinMultiplatformExtensionDelegate now use these helpers instead of direct KotlinAndroidTarget/platformType checks, so gobley works with both the classic com.android.library KMP target and the new com.android.kotlin.multiplatform.library target introduced in AGP 8+.
Summary
com.android.library/com.android.application) and the Android KMP library plugin (com.android.kotlin.multiplatform.library)androidJvm) in Cargo and UniFFI task planningtests:gradle:android-kmp-library) and include it in gradle test project setVerification
./gradlew :build-logic:gobley-gradle-cargo:test :build-logic:gobley-gradle-uniffi:test./gradlew :tests:gradle:android-kmp-library:assemble -Pgobley.projects.examples=false -Pgobley.projects.uniffiTests=false -Pgobley.projects.gradleTests=true./gradlew :tests:gradle:android-linking:assemble -Pgobley.projects.examples=false -Pgobley.projects.uniffiTests=false -Pgobley.projects.gradleTests=true