Writing Your First SymbolProcessor
Implement a KSP processor that scans for annotated classes and logs them.
Project Structure
A KSP processor lives in a separate Gradle module (e.g., :processor). The consuming module applies the KSP plugin and declares a ksp dependency on the processor module. The processor module itself has a regular implementation dependency on the KSP API.
Adding KSP Dependencies
In your processor module's build.gradle.kts:
plugins { kotlin("jvm") }
dependencies {
implementation("com.google.devtools.ksp:symbol-processing-api:2.0.0-1.0.21")
}All lessons in this course
- KSP vs KAPT: Why KSP Is Faster
- Writing Your First SymbolProcessor
- Generating Kotlin Source Files with KotlinPoet
- Integrating KSP Processors into a Gradle Build