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

spierce7

06/24/2019, 2:33 AM
Using the
multiplatform
plugin, if I have test sourcesets dependOn other sourcesets, I can't access the
internal
code of those source sets. I have a sourceSet that is generated code, so I separate it, and those tests that depend on the generated code, and the common code can't access the internal code of the common source set. My configuration is inside the thread.
Copy code
kotlin {
    jvm {
        compilations.all {
            kotlinOptions.jvmTarget = "1.8"
        }
    }

    @Suppress("UNUSED_VARIABLE")
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(Libs.kotlin.stdlib.common)
            }
        }

        val commonTest by getting {
            dependencies {
                for (lib in Libs.kotlin.test.common) {
                    implementation(lib)
                }
            }
        }

        val genMain = create("genMain") {
            dependsOn(getByName("commonMain"))
        }

        val commonAndGenTest = create("commonAndGenTest") {
            dependsOn(commonTest)
            dependsOn(genMain)

            dependencies {
                for (lib in Libs.kotlin.test.common) {
                    implementation(lib)
                }
            }
        }

        val jvmMain by getting {
            dependsOn(genMain)

            dependencies {
                implementation(Libs.kotlin.stdlib.jvm)
            }
        }

        val jvmTest by getting {
            dependsOn(commonAndGenTest)

            dependencies {
                implementation(Libs.kotlin.test.jvm)
            }
        }
    }
}
3 Views