I have only just now begun the process of migratin...
# multiplatform
p
I have only just now begun the process of migrating an Android app to KMP. It is a very unusual app (intentionally as part of a research effort) that is comprised of dozens of projects: one App (Android) project, many UI (jetpack compose) library projects and even more JVM (pure Kotlin) library projects. It is very clear that the App and UI projects must be converted to KMP (to add iOS target) but it is not clear to me at all that the JVM projects need to be modified. So the question: is it the case that a pure Kotlin JVM library can be consumed by a KMP app directly, without any modifications either to the source code or the jar files? The answer I am looking for is either "yes" or "no, and here's what you need to do because...", preferably in a thread. At the moment, I am assuming the answer is "yes", fwiw.
i
> is it the case that a pure Kotlin JVM library can be consumed by a KMP app directly in the sense of what you're asking, no. You can have your JVM targets use JVM only code but your non JVM targets can not use that source.
I've converted a lot of JVM code to KMP and for the most part just change the configuration of the model to KMP and move all the source to
src/common/kotlin
and you're good. The issues arise if that module has JVM only dependencies/works with dates and times/has sdk dependencies like android/etc. You have to break that functionality out into specific targets or modules as appropriate.
p
Thanks @ian.shaun.thomas for responding. I am interpreting your response as: "No, You need to move your JVM only source code to src/common/kotlin, update the build scripts to KMP and rebuild in order to catch any KMP code that needs expect/actual intervention" This seems reasonable now that I think about it. Unfortunate, but reasonable. Since you have converted lots of JVM code to KMP have you developed any automation to make it easier or is it manual every time?
i
no automations, it's too infrequent and usually you're making so many structural changes and misc changes it wouldn't make sense. If you have legit java code you can use the built in java to kotlin converter in intellij which is helpful.