KSP vs KAPT: Why KSP Is Faster
Compare KSP and KAPT processing models and understand the performance benefits.
The Problem with Annotation Processing
Annotation processors generate code at build time. For years, Kotlin projects used KAPT — Kotlin Annotation Processing Tool — which works by converting Kotlin source to Java stubs before passing them to Java annotation processors. This conversion is costly.
How KAPT Works
KAPT runs the Kotlin compiler to produce Java stub files, then runs Java annotation processors (APT) on those stubs, then compiles everything together. Every build step adds latency:
- Kotlin → Java stubs compilation
- Java APT processing on stubs
- Final Kotlin + generated-source compilation