Annotation Processing in a Kotlin World
summary
Kapt’s Java stub output hides Kotlin specifics, so read the class’s @kotlin.Metadata protobuf to recover default values, nullability, mutability and primary-constructor mappings; this fixes real Dagger quirks (wildcard lists, qualifier targets, companion static methods) and offsets kapt slowness. Uses: the community library kotlin-metadata (and JetBrains’ kotlinx-metadata visitor API) plus KotlinPoet to generate Kotlin. Examples built: a working copyDynamic generator and Moshi adapters (Moshi uses this approach); compiler plugins exist but are unstable.
AI-written summary · about
chapters (6)
- 0:00Start
- 32:37Metadata is added signal
- 33:03Abstract your renderer
- 34:38Be mindful of mixed source sets
- 35:59Lean on language features
- 37:05Be mindful of quirks and caveats
related talks
44mExploiting Kotlin Metadata + Annotation Processing
39mAnnotation processing for Kotlin done right
23mGenerating Kotlin extension functions for Annotation Processing
36mFact or kapt? Build your next annotation processor with KSP
09mWorking Around KAPT
36mExploring Kotlin Symbol Processing: A Practical Guide
41mGenerating Kotlin Code
28mMetaprogramming with Kotlin Symbol Processing
