Davide Giuseppe Farella
10/31/2022, 1:33 PMkspCommonMainMetadata(libs.arrow.optics.ksp)
add("kspJvm", libs.arrow.optics.ksp)
then I’ve added
kotlin{
sourceSets.all {
kotlin.srcDir("build/generated/ksp/${this.name}/kotlin")
}
}
and I see the code generated under
• generated/ksp/jvm/jvmMain/kotlin
• generated/ksp/metadata/commonMain/kotlin
But the generated code is not resolved
I believe I’m missing something in the setup (?)Davide Giuseppe Farella
10/31/2022, 1:37 PM./gradlew build
I see
> Task ⏱️playersdatakspCommonMainKotlinMetadata FAILED
e: [ksp] java.lang.NullPointerException: null cannot be cast to non-null type java.util.ArrayList<com.google.devtools.ksp.symbol.KSType>{ kotlin.collections.TypeAliasesKt.ArrayList<com.google.devtools.ksp.symbol.KSType> }
at arrow.optics.plugin.internals.ProcessorKt.targetsFromOpticsAnnotation(processor.kt:51)
simon.vergauwen
10/31/2022, 3:26 PMcommonMain
? or do you have code inside jvmMain
also?
Can you combine kspCommonMainMetadata
with add("kspJvm"
? 🤔simon.vergauwen
10/31/2022, 3:27 PMDavide Giuseppe Farella
10/31/2022, 3:53 PMcommonMain
.
What do you mean with
Can you combineI thought that was the way to go, is the first time I’m trying KSP to be honest and I’ve read thatwithkspCommonMainMetadata
? 🤔add("kspJvm"
ksp()
is not suggested and will be removedDavide Giuseppe Farella
10/31/2022, 3:53 PMsimon.vergauwen
10/31/2022, 4:03 PMksp
specific commands are being removed. I am not sure what kspCommonMainMetadata
does under the hood but it might be conflicting with add("
.
Actually, on second look. You say that the generated code is not recognised but is being generated so that is not the problem.
I believe this is not correct.
kotlin{
sourceSets.all {
kotlin.srcDir("build/generated/ksp/${this.name}/kotlin")
}
}
But not entirely sure how to link it for Kotlin MPP code. 🤔
Maybe:
kotlin{
sourceSets.all {
kotlin.srcDir("build/generated/ksp/jvm/jvmMain/kotlin")
kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin")
}
}
Davide Giuseppe Farella
10/31/2022, 5:05 PMkspCommonMainMetadata
is the “typed” alternative to add("kspCommonMainMetadata",
I will try your suggestion in a sec, thank youDavide Giuseppe Farella
10/31/2022, 5:16 PMkotlin{
sourceSets.all {
kotlin.srcDir("build/generated/ksp/jvm/jvmMain/kotlin")
}
}
About the code to be generated, it was my mistake, Arrows does generates under JVM only, the code under metadata was from KoinDavide Giuseppe Farella
10/31/2022, 5:21 PMDavide Giuseppe Farella
10/31/2022, 5:25 PM