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

bdeg

11/17/2018, 5:20 PM
Hi, I'm trying to build my first multi platform project using the new multi platform plugin. Before I used to build the platform apps as sub-modules but now it's as sourcesets can someone explain why jetbrains decide to switch to sourcesets and is it possible to still use the new plugin but with the submodule fashion?
🤔 1
s

serebit

11/17/2018, 6:05 PM
As someone who’s worked with both, the source set method has a much more simplified configuration and isn’t as much of a hassle to set up
And adding new targets is as simple as two lines of code, one in sourcesets to create the source set and one in targets to create the target
No need for separate buildscripts per module
Which is why you have includes, so you can toss parts of the main buildscript into the
gradle
folder.
b

bdeg

11/17/2018, 6:51 PM
Yes, I'm already experiencing with it, right now... It's kind of a big migration from the first way. Can we actually apply the multi platform on sub-modules? Just like if we were building a library?
s

serebit

11/17/2018, 7:20 PM
Yep! That’s actually what I’m doing with one of my projects. I have the runtime in one module, which is multiplatform, and samples in another module.
b

bdeg

11/17/2018, 8:43 PM
Is your project open source?
s

serebit

11/17/2018, 9:13 PM
e

egorand

11/19/2018, 12:23 AM
Also, you can leave the project structure as is and override source set paths to point into the modules, so that your JVM code would live in
jvm/src/main/kotlin
vs
src/jvmMain/kotlin
👍 1
b

bdeg

11/19/2018, 8:16 AM
Great idea, I kind of did the same thing to get the android preset working with the android.library plugin
a

Alexey Belkov [JB]

11/21/2018, 12:04 PM
can someone explain why jetbrains decide to switch to sourcesets
See https://youtrack.jetbrains.com/issue/KT-23930
e

egorand

11/21/2018, 12:43 PM
I feel though that a lot of flexibility, that came from treating targets as separate modules, has been lost in the process
Configuring very simple projects seems easy and natural, but when you have something more complex you have to fight the plugin
2 Views