Is there a way to make a common `posix` source set...
# multiplatform
s
Is there a way to make a common
posix
source set that has access to
platform.posix
, which both
macos
and
linux
depend on? Or do I just have to copy-paste everything between the two source sets. Edit: Seems like it's possible, but IntelliJ doesn't seem to like it.
p
My first take on solving this problem would be to create a Kotlin/Native library where the common code is in the nativeMain source set. Then both both your macos and linux source sets would have a dependency on this new native library.
m
AFAIK this will be supported in 1.3.20, for now you can use workaround like this:
Copy code
sourceSets {
        linuxMain {
            kotlin.srcDir('src/posixMain/kotlin')
        }
        macosMain {
            kotlin.srcDir('src/posixMain/kotlin')
        }
    }
👌 4
t
@serebit could you share your solution? I tried creating a new source set called "nativeMain" which Linux/Mac depend on, but I can't access
kotlin.native...
code in nativeMain.
s
I just used Mike’s workaround. Creating a
nativeMain
source set works with Gradle, but not IntelliJ.
x
So how about Gradle Koltin DSL?
Figured it out, but IDE can recognize it.