Hey, I've recently started playing with a Kotlin Multiplatform. I have a bunch of native targets and I wanted to group them under
nativeMain
target. I did this:
val commonMain by sourceSets.getting
val commonTest by sourceSets.getting
val nativeMain by sourceSets.creating
nativeMain.dependsOn(commonMain)
targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget>().all {
val mainSourceSet = compilations.getByName("main").defaultSourceSet
val testSourceSet = compilations.getByName("test").defaultSourceSet
mainSourceSet.dependsOn(nativeMain)
testSourceSet.dependsOn(commonTest)
}
I also added
Okio
library as a dependency in
commonMain
.
Now I'm trying to use Okio in a kotlin file inside
nativeMain
directory but it doesn't work. Looks like the dependency is not being correctly picked up.
If instead of creating this custom
nativeMain
source set I just use a single one like
macosX64
and then put my kotlin file inside
macosX64
directory then I can use the Okio and it works fine.
What am I doing wrong that the dependency doesn't work in my custom
nativeMain
source set?