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

Shan

01/12/2020, 3:11 AM
Trying to get a set up that looks like this:
Copy code
jvmCore
  |_ main
       |_ kotlin
  |_ test
       |_ kotlin
instead of
Copy code
jvmCoreMain
  |_ kotlin
jvmCoreTest
  |_ kotlin
But can't quite figure out how to configure my sourceSets properly. I have it set up like this:
Copy code
sourceSets {
    jvm().compilations {
        val core by creating {
            defaultSourceSet {
                dependencies { //etc }
            }
        }
        val coreTest by creating {
            defaultSourceSet {
                dependencies { //etc }
            }
        }
    }
}
Is it possible to set it up more like..
Copy code
sourceSets {
    jvm().compilations {
        val core by creating {
            sourceSet("main") {
                dependencies {}
            }
            sourceSet("test") {
                dependencies {}
            }
        }
    }
}
?
d

Dominaezzz

01/12/2020, 3:21 AM
Copy code
sourceSets {
    jvm().compilations {
        "main" {
            defaultSourceSet {
                kotlin.srcDir("src/jvmCore/main/kotlin")
                dependencies { //etc }
            }
        }
        "test" {
            defaultSourceSet {
          kotlin.srcDir("src/jvmCore/test/kotlin")
                dependencies { //etc }
            }
        }
    }
}
That should give you the setup you want.
s

Shan

01/12/2020, 3:25 AM
Hmm, that will work but I have other jvm sourceSets (two more) as well that will need "main" and "test" sourceSets of their own which will cause conflicts with this setup I believe.
I can do something like
Copy code
val core by creating {
    sourceSets {
        create("main") {
            dependencies {}
        }
        create("test") {
            dependencies {}
        }
    }
}
But it only seems to generate
jvmCore/main
and not
jvmCore/test
. 🤔
ah, I see it is because it's using the project's
sourceSets
not `core`'s.. hmm