Hello all. Does anyone have a link to a large grad...
# multiplatform
s
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
Unsure if this uses other modules, but feel free to check this out https://github.com/JetBrains/kotlinconf-app
s
Thanks, this is a good example, although there are no complex module dependencies
j
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
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
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
Maybe not comolex enough, but here's a small project with two layers of common dependencies https://github.com/russhwolf/multiplatform-hello
👍 1