https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
p

pdvrieze

11/22/2017, 10:59 AM
I have a case that I'm not sure is supported. Basically I have a library that provides XML related functions for Android, JVM and JS with a common api. All three targets have different underlying libraries that I will use. At the same time Android and JVM do share some commonalities that are not present for JS. As such I would like to have a common module ("common-android-jvm") that provides the implementation for some expects as that are declared in the fully common module. It doesn't seem possible to do that. Of course the android and jvm modules could duplicate the code (but I'd like to avoid that). Anyone know whether this is an oversight of me, or is this a "missing" feature
👍 1
g

gildor

11/23/2017, 2:48 AM
Maybe you can do something like that: Android and JVM can have one more shared module with shared JVM code. both Android and JVM just use standard JVM ways like interfaces, DI and so on to provide different implementations of some parts, but use some base library So structure will be something like
Copy code
[Android]  [JVM] //compile project(":common-jvm")
     |      |
     V      V
   [common-jvm] //implement project(":common-multiplatform")
        |
        V
[common-multiplatform] // Provides "expect" API
I mean multiplatform projects created to allow have completely different implementations for different platforms,for JVM/Android you can still use abstractions to provide different implementations, because you still can share them easily using JVM build tools, dependencies and so on
p

pdvrieze

11/29/2017, 9:48 AM
I will probably just do multiple implementations of the common bits or use common base classes for shared code.