I'm in the process of upgrading my kotlin version ...
# ksp
p
I'm in the process of upgrading my kotlin version from
2.1.20
-> and
2.2.10
, along with ksp from
2.1.20-1.0.32
->
2.2.10-2.0.2
and since the upgrade, I am seeing some code generation issues. In my multiplatform project, I have an annotation processor that generates some code based off the class it is attached to. In addition to this annotation processor, I have a custom gradle plugin that needs to use the output of the annotation processor to function properly. Before the version upgrades, I linked the annotation processor to the gradle plugin via:
Copy code
target.tasks.withType<KspTaskMetadata>().all {
            saveStateTask.dependsOn(this)
        }

        target.tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>>().all {
            if (name != "kspCommonMainKotlinMetadata") {
                dependsOn("kspCommonMainKotlinMetadata")
            }
        }
So that
kspCommonMainKotlinMetadata
will run first and all the necessary code will be generated. Then the
saveStateTask
(what the custom gradle plugin runs) is dependent on
kspCommonMainKotlinMetadata
as well. Since the upgrade, I have had to change those dependencies to this since the types have changed:
Copy code
target.tasks.withType<KspAATask>().all {
    if (name == "kspCommonMainKotlinMetadata") {
        saveStateTask.dependsOn(this)
    }
}

target.tasks.withType<KotlinCompilationTask<*>>().all {
    if (name != "kspCommonMainKotlinMetadata") {
        dependsOn("kspCommonMainKotlinMetadata")
    }
}
However, after this change, on subsequent builds of any client, the ksp annotation processor will not generate any code, as it does not resolve any symbols. So it seems like the ksp compilation tasks sometimes do not run prior to resolving the annotations. Does anyone have any ideas what I could look to improve on?
r