Oliver.O
06/07/2022, 6:24 PMcompileCommonMainKotlinMetadata
?
Second question in 🧵.Oliver.O
06/07/2022, 6:25 PMkotlin {
jvm {
withJava()
}
js(IR) {
browser()
}
sourceSets {
val commonMain by getting {
}
val clientMain by creating {
dependsOn(commonMain)
}
val jvmMain by getting {
dependsOn(clientMain)
}
}
}
Why is there an extra metadata compilation for commonMain
but not for the custom intermediate clientMain
source set?Oliver.O
06/08/2022, 11:34 AMdmitriy.novozhilov
06/08/2022, 2:59 PMdsavvinov
06/08/2022, 3:54 PMjsMain.dependsOn(clientMain)
, it will become a usual shared source set (similar to commonMain in that regard), and the metadata should be created for itOliver.O
06/08/2022, 4:23 PMcompileCommonMainKotlinMetadata
. KSP processors are currently not source set-aware. A KSP processor generating code for commonMain
sees the same code again and re-generates identical code for a target compilation, leading to Redeclaration
errors. To resolve this, we have to provide the processor with source set information to make informed decisions. I just wanted to make sure that this multiple-compilation strategy is still needed and we can not just skip the common metadata compilation.
I did already guess that the whole metadata thing is for library sharing, but was not sure whether this was superseded by current Klibs and all that. I still wonder why the compiler cannot just generate common code in a target compliation when it detects that it is not yet there (or non-current). I'll experiment with your Js suggestion to figure out how to handle cases involving multiple common code sets. Thanks again!dsavvinov
06/08/2022, 8:42 PMOliver.O
06/08/2022, 8:50 PM