Kotlin Symbol Processing (KSP) is an API for developing lightweight compiler plugins for Kotlin.
KSP addresses the need for efficient code generation and compile-time metaprogramming in Kotlin projects. It provides a simplified compiler plugin API that reduces the learning curve compared to lower-level compiler plugin development. The tool processes Kotlin symbols during compilation, allowing annotation processors and other code generation tools to inspect and manipulate code structure at compile time.
Developers should choose KSP when building annotation processors, code generators, or other compile-time tools for Kotlin projects. It suits any project that currently uses or is considering annotation processing, particularly those where build performance matters. The README explicitly compares KSP to KAPT, noting that annotation processors using KSP can run up to twice as fast. The tool supports single-platform JVM and Android projects as well as multiplatform Kotlin projects, with configuration guidance provided for Gradle-based builds.
The project maintains comprehensive documentation covering quickstart guides, examples, and detailed reference material for both Kotlin and Java annotation processor authors. It includes specific guidance on incremental processing, multiple round processing, and command-line usage. The tool provides support for testing and debugging both processors built with KSP and the KSP infrastructure itself through dedicated development documentation.