While KSP is still in the Alpha version, the Google-developed API which is similar to the Kapt compiler plug-in for annotation processing, is faster and offers direct access to Kotlin compiler capabilities.
It is designed to obscure compiler changes and as implemented as a compiler plug-in itself, it minimizes maintenance efforts.
What the Kotlin Symbol Processing API brings to the table
The KSP API is for directly parsing Kotlin code, which reduces the build speed tax imposed by Kapt stub generation. And as Kotlin lacks a native annotation processing system, albeit annotation processors like Room for Kotlin does exist, there is a library for KSP that acts as a normal annotation processor.
During the alpha phase, it is recommended that KSP and Kapt should be maintained in separate modules. As KSP and the Kapt compiler plug-in for annotation processing, when used in the same module will likely slow down a build initially and it must be maintained in separate modules.
However, as more and more annotation processors adopt KSP, the tool will become a simple drop-in replacement for Kapt.
How to Get Started with Kotlin Symbol Processing API
If you're a developer and want early access to KSP, the source code and documentation is available on GitHub. And you can also see what KSP feels like via the KSP Playground project.
With Kotlin as a viable choice for Android app development, KSP is built with the goal of being multiplatform compatible so that it won't be tied to the JVM. The compatibility with Kotlin 1.34.0, means that KSP will act like a preprocessor framework for Kotlin programs.
No comments