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

Hauke Radtki

04/04/2019, 8:00 AM
I have a MPP module with JVM, Android and iOS targets. I want to have another JVM module depend on the MPP module. This currently fails because the MPP module has to apply the Android plugin and the jvm module complains about that it can not depend on a project that applies the android plugin. My current workaround is to publish the MPP to mavenLocal and then depend on that. But this looks hackish to me and is error prone (not to forget to publish to mavenLocal ...)
s

Sergio Casero

04/04/2019, 9:55 AM
Yo could target the `common`module to `JVM`and `iOS`only
And then, the other one, target also to android
My arch is more or less like this one: 1.
common
module targeting
jvm
,
ios
and
js
2.
common-client
targeting also
android
h

Hauke Radtki

04/04/2019, 9:56 AM
Not possible because I want to have my models (which reside in common) to implement Parcelable. That's why I need an android target 😕
s

Sergio Casero

04/04/2019, 9:57 AM
jmmm, why? You could create pojo for views, and then map the models
Something like...
Person
and
PersonView
h

Hauke Radtki

04/04/2019, 9:58 AM
That would include at least some duplication I would like to avoid.
s

Sergio Casero

04/04/2019, 10:00 AM
Yes... I always try to work with simple data class, why do you need parcelable?
You could pass only the id between screens for example
h

Hauke Radtki

04/04/2019, 10:02 AM
Also Person & PersionView does not work if I want to utilize the Kotlin parcelize Plugin
And the Backend uses a NoSQL store, so not every entity has an ID
s

Sergio Casero

04/04/2019, 10:03 AM
jmmmm
h

Hauke Radtki

04/04/2019, 10:04 AM
I mean, it's working. Im just curious if there are any means for a project dependency to express/resolve the target it needs.
s

Sergio Casero

04/04/2019, 11:27 AM
Yes yes, I'm just thinking about how to handle it
hahah
I'm also curious now
h

h0tk3y

04/04/2019, 12:03 PM
@Hauke Radtki You can have both JVM and Android targets in a multiplatform project, and then the other JVM project that depends on it should be fine. The current limitations are: 1) you can't use Java in the code for the MPP JVM target, it will only compile Kotlin, and 2) the code that you share between Android and JVM targets cannnot use JVM-specific language features and dependencies, it should be platform-agnostic.
h

Hauke Radtki

04/05/2019, 9:39 AM
@h0tk3y
Copy code
------ Java Application module
							 /
MPP module (JVM, Android, ios)
							 \
							   ------ Android Library module
I'm using the
org.jetbrains.kotlin.multiplatform
plugin. Thats why the MPP module contains a source set per target. And because I want to use Android features within the Android sourceSet of the MPP module, I have to apply the
com.android.library
plugin for the whole MPP module. This is what causing the JVM module dependency to fail. Also of course I need to have java code in the JVM and Android targets, as I'm having several expect/actual declarations that map to target specific types. So under these circumstances: Is there a way to more cleanly express module dependencies than publishing to mavenLocal?