Hey! I was <redirected> to ask here about this . H...
# ksp
z
Hey! I was redirected to ask here about this . How does KSP support K2 and generation of resources during AnalysisHandlerExtension?
t
KSP has its own Gradle tasks separated from the compilation. It registers generated stuff via Gradle and doesn't need special support from the compiler. In command line mode, we simply give up supporting processing-and-compilation in a single invocation with K2. Moreover, with K2, KSP is no longer a compiler plugin. It is being rewritten using an abstraction layer on top of K2. KSP 2.0 acts more like the IDE, that it sets up the compiler environment and calls the compiler as a service.
z
Interesting, so it’s purely because it has its own KspTask? It would it also work ok if it was running during the regular KotlinCompile task (I don’t remember the exact option but I know theres one to run within the same kotlin task and non-incrementally)
t
Yes. In KSP 1.x, that mode is only available in command line mode but not in Gradle (dropped before KSP 1.0 beta). With K2, it is going to be dropped completely.
z
what's "it" in this case - generating resources or running as a compiler plugin?
t
I mean generating resources and doing compilation in a single compiler invocation.
so it’s purely because it has its own KspTask
Yes, In Gradle, because KSP has its own task, the restriction of AnalysisHandlerExtension doesn't apply to us. In KSP command line mode, we also suffer from it in K2.
z
👍 thanks for the insight