Hi. My processor generates functions with the same...
# ksp
p
Hi. My processor generates functions with the same names as certain annotated interfaces, e.g.
interface MyInt
will produce
fun MyInt(): MyInt {...}
which is located in the same package as the interface. The problem is that IDE doesn’t see the generated functions and gives a warning that “Interface doesn’t have constructors” when using them, but the functions can be found in
build/generated/ksp
and the code compiles successfully. Is there a way to make IDE detect it?
1
The problem is: the code is not generated in
commonMain
but only per platform, so it can’t be resolved
I think I was able to fix this with the following:
Copy code
dependencies {
    add("kspCommonMainMetadata", "[my-processor]")
}

kotlin.sourceSets.commonMain {
    kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin")
}

tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>>().configureEach {
    if (name != "kspCommonMainKotlinMetadata") {
        dependsOn("kspCommonMainKotlinMetadata")
    }
}
See issue
🙌 1