handstandsam / kmp4free

A Gradle Plugin that allows seamless switching between Kotlin JVM and the Kotlin Multiplatform Plugins
Apache License 2.0
62 stars 1 forks source link

Do you want to support Android modules? #6

Closed LouisCAD closed 2 years ago

handstandsam commented 2 years ago

Good question. With this plugin, all your code gets resolved as commonMain. So, that being said, you wouldn't want platform specific code (Android only code) to be in this module.

You can move from an com.android.library to org.jetbrains.kotlin.jvm if you:

If you can make that move, then you can additionally make the move from org.jetbrains.kotlin.jvm to com.handstandsam.kmp4free

So, my thought here is that someone using this library could migrate their Android library to use kotlin("jvm") aka org.jetbrains.kotlin.jvm, and then use this plugin after that.

Maybe that's a blog post? It's what I was getting at with this slide:

Screen Shot 2022-06-06 at 8 59 54 AM

Full Deck: https://speakerdeck.com/handstandsam/embracing-commonmain-for-android-development-droidcon-sf-2022


I'm sure this will be a common question though. What would you suggest based on what I've shared above?

handstandsam commented 2 years ago

Once someone is at the point of needing the Android platform-specific code in this module, I would recommend they not use this library anymore. kmp4free is a good mechanism for the testing/migration of KMP, but I think you'd want to just move to the kotlin("multiplatform") plugin if you wanted more than commonMain compatible code like this suggests.

handstandsam commented 2 years ago

I think the identification of these modules could be done as a feature of dependency-analysis-android-gradle-plugin: https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin/issues/751.