# multiplatform


02/28/2019, 12:11 AM
Basic Gradle/MPP question: The example Gradle/MPP setups I can find online seem to be split into two definite camps: 1. Define all platforms in one module with different source sets. 2. Define each platform in it's own module, referencing another Common module - each module containing only one source set. Can anyone suggest the pro/con of each setup and why they are both presented? It's quite confusing for a newcomer to be presented with both of these as 'the way to do multi-platform'. Personally, separate modules with one source-set per module feels more natural to me: - Follows established Gradle conventions - Doesn't require learning new knowledge of Gradle's often opaque data-structures (how to configure target within module, rather than module directly) - Keeps the platform modules more loosely coupled, not defined in the same file


02/28/2019, 12:41 AM
Hate to break it to you, but #1 is the new way of doing things, and #2 is the old way of doing things. Many projects are still transitioning, but as far as I understand, #1 is generally the way of the future.
☝🏻 1


02/28/2019, 7:21 AM
Well, you can do approach #2 with new way too. Used alongside #1, it can make sense in some cases for more code reuse.


02/28/2019, 7:58 AM
Sigh that's disappointing. TBH unlike every other technology, it's never felt to me like there's any logic behind Gradles syntax - the DSL is madness and each plugin only heaps more arbitrary patterns on top - time for more learning by rote 😕
👍 1


02/28/2019, 8:16 AM
The logic behind Gradle syntax is Groovy. Once you grasp it everything starts looking pretty sound to you.
😣 1
🤞 1


02/28/2019, 8:20 AM
As there still seem to be many problems with more complex mpp sourcesets, the best approach I came across is to split projects into a common module with its respective sourcesets and separate gradle modules which depend on the common module. here is an example:


02/28/2019, 8:23 AM
Starting with a single build.gradle is simpler. And that’s totally fine for small size projects.