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

serebit

12/08/2018, 5:35 AM
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

pajatopmr

12/08/2018, 6:50 AM
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

msink

12/08/2018, 7:30 AM
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

Thomas

03/05/2019, 2:09 PM
@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

serebit

03/05/2019, 3:37 PM
I just used Mike’s workaround. Creating a
nativeMain
source set works with Gradle, but not IntelliJ.
x

XQDD

09/30/2019, 1:57 PM
So how about Gradle Koltin DSL?
Figured it out, but IDE can recognize it.
3 Views