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

Siggi Gunnarss

06/16/2020, 9:42 AM
Hello all. Does anyone have a link to a large gradle android/ios mpp project? Most samples are rather small. I'm looking for something that has multiplatform modules depending on other multiplatform modules?
h

Hamza

06/16/2020, 9:43 AM
Unsure if this uses other modules, but feel free to check this out https://github.com/JetBrains/kotlinconf-app
s

Siggi Gunnarss

06/16/2020, 10:07 AM
Thanks, this is a good example, although there are no complex module dependencies
j

Jurriaan Mous

06/16/2020, 11:05 AM
I have a for now internal project which will at some moment be opened up and works with multiple layers of multiplatform dependencies. Is there anything specific you want to know? An example of a module depending on a different module in same project. I abstracted each platform setting into its own .gradle file so I avoid duplication.
Copy code
plugins {
    id("kotlin-multiplatform")
}

apply {
    from("../gradle/common.gradle")
    from("../gradle/js.gradle")
    from("../gradle/jvm.gradle")
    from("../gradle/native.gradle")
    from("../gradle/publish.gradle")
}

kotlin {
    sourceSets {
        commonMain {
            dependencies {
                api(project(":yaml"))
            }
        }
        commonTest {
            dependencies {
                implementation(project(":testmodels")) {
                    // Workaround for: <https://youtrack.jetbrains.com/issue/KT-33712>
                    exclude(module = "core")
                }
            }
        }
    }
}
s

Siggi Gunnarss

06/16/2020, 1:13 PM
That's very helpful, thanks. The platform gradle abstraction makes a lot of sense. So you only have to reference api(:yaml) in commonMain source sets, not nativeMain etc.?
j

Jurriaan Mous

06/16/2020, 1:15 PM
Only commonMain, just like you do with the recent multiplatform dependencies. Kotlin multiplatform gradle plugin takes care of the rest.
👍 1
In the past there were issues with transitive project dependencies but that all got fixed along the way 🙂 https://youtrack.jetbrains.com/issue/KT-28019
r

russhwolf

06/16/2020, 1:45 PM
Maybe not comolex enough, but here's a small project with two layers of common dependencies https://github.com/russhwolf/multiplatform-hello
👍 1
6 Views