spierce7
04/18/2023, 1:02 AMVariable 'commonMain' is never used
in our Kotlin multiplatform modules:
sourceSets {
val commonMain by getting {
dependencies {
}
}
It'd be nice if there was a way to ignore this error or turn it off for the whole project.ephemient
04/18/2023, 1:04 AM@Suppress("UNUSED_VARIABLE")
but I just use
sourceSets {
getByName("commonMain") {
dependencies {
}
}
when the variable would be unusedephemient
04/18/2023, 1:05 AMAdam S
04/18/2023, 6:36 AMcommonMain
is created proactively in the Kotlin Multiplatform plugin, it should have a DSL accessor generated if you use .gradle.kts
, so you can do
sourceSets {
commonMain { // generated accessor
...
}
}
Adam S
04/18/2023, 6:43 AM// buildSrc/src/main/kotlin/my-kotlin-mp-convention.gradle.kts
plugins {
kotlin("multiplatform")
}
kotlin {
jvm()
sourceSets {
create("foo") { ... }
}
}
// my-subproject/build.gradle.kts
plugins {
id("my-kotlin-mp-convention")
}
kotlin {
sourceSets {
jvmMain { }
foo { }
}
}
And just like that, no warnings about unused variablesEmil Kantis
04/18/2023, 5:19 PM