Exploring Kotlin Symbol Processing: A Practical Guide
summary
Demonstrates using Kotlin Symbol Processing (KSP) plus KotlinPoet to auto‑generate mapper interfaces and implementations (Peoplehub: Person ↔ PersonEntity), with a multi‑module setup (app, annotation, processor), KSP invoked during Gradle builds and writing files to build/generated/ksp. Notes KSP is Kotlin‑compiler‑version specific, up to two times faster than KAPT per Google, cannot modify existing source or inspect expressions, and supports multiplatform and K2 (KSP 2 in beta). Generated DBMapper and Impl compile and log from the processor.
AI-written summary · about
chapters (17)
- 0:00Introduction
- 1:29What is KSP
- 3:13KAP and compiler plugin limits
- 4:58Why choose KSP
- 7:30Setting up KSP in Gradle
- 9:14How KSP models code
- 12:34Practical KSP demo
- 16:48Project architecture and mapper gen
- 18:16Custom annotations for KSP
- 20:43Implementing symbol processor
- 23:12KSP resolver and code gen
- 25:38Code gen with Kotlin Poet
- 27:24Extracting annotation params
- 28:48Mapper interface and impl
- 30:57Adding functions to mappers
- 33:25KSP in multiplatform projects
- 34:06Future plans and summary
related talks
35mExploring Kotlin Symbol Processing: A Practical Guide
37mWhy you should positively consider introducing and migrating to KSP
25mCode Generation Using Kotlin Symbol Processing (KSP)
47mDealing With KSP in Common Code for Android and iOS
28mMetaprogramming with Kotlin Symbol Processing
36mFact or kapt? Build your next annotation processor with KSP
26mBuild your own compiler with KSP
33mMeta-programming with KSP and Kotlin compiler plugins
