im not very proficient with gradle, but is there a...
# multiplatform
j
im not very proficient with gradle, but is there a way of adding build variants to my server module? id like to be able to split server config based on release/debug
h
It depends on your setup. If you use the kotlin JVM plugin, it is easy: Gradle supports multiple SourceSet (like main, test, testFixtures, integrationTest…) at the lower level that actually contains the files (and some configurations). Each sourceSet is compiled separately. If you talk about variants, there are Gradle Java Features, that basically uses a SourceSet and makes it available to other (external) Gradle modules (via variants).
If you want to use variants with the Kotlin Multiplattform Plugin, you need to configure compilations of a Kotlin target manually, and afaik you can’t consume them from another Gradle module.
j
i came up with this
Copy code
kotlin {
    sourceSets {
        val main by getting {
            kotlin.srcDir("src/main/kotlin")
            resources.srcDir("src/main/resources")

            if (buildType == "debug") {
                kotlin.srcDir("src/debug/kotlin")
                resources.srcDir("src/debug/resources")
            } else {
                kotlin.srcDir("src/release/kotlin")
                resources.srcDir("src/release/resources")
            }
        }
        val test by getting
    }
}
e
that is definitely not what I'd recommend. you can only build one variant at a time, and only one will be in the IDE model
using compilations as variants works fine, you just have to set up the configurations for exporting by hand in KMP Gradle
j
@ephemient can you show an example of what you'd recommend?