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
hfhbd
05/16/2025, 12:15 PM
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).
hfhbd
05/16/2025, 12:17 PM
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
Jay
05/16/2025, 1:49 PM
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
ephemient
05/16/2025, 10:11 PM
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
ephemient
05/16/2025, 10:12 PM
using compilations as variants works fine, you just have to set up the configurations for exporting by hand in KMP Gradle
j
Jay
05/19/2025, 9:45 AM
@ephemient can you show an example of what you'd recommend?