The Lazy (Meta)programmer's Guide to Hilt Extensions
summary
Claim: replace repetitive Dagger binding modules with one annotation that KSP generates into installable Hilt modules. Uses KSP and KotlinPoet to implement an Autobind symbol processor that emits abstract @Module classes and @Binds methods, and requires annotating the annotation with generatesRootInput so Hilt consistently picks up generated code. At scale this avoids writing ~1,000 boilerplate classes (example: 100 modules × 10 bindings); the extension approach proves feasible and defaults to SingletonComponent.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 1:08Defining meta programming
- 3:18Reflection vs code generation
- 6:35Laziness and productivity
- 11:50Dagger module boilerplate
- 16:27Hilt Extensions for chicken-and-egg
- 18:12Hilt extension annotation
- 20:47KSP plugin for Hilt Extensions
- 27:33Q&A
related talks
32mUsing Hilt in a Multi-Module Project
40mPlugging into Anvil and powering up your dependency injection
46mCodegen with KSP: A Farewell to Stubs
36mFact or kapt? Build your next annotation processor with KSP
37mWhy you should positively consider introducing and migrating to KSP
42m(Unofficial) Guide to App Architecture Guide Vol. 2
25mFully Understanding Dagger Hilt Migration from First Principles
45mDagger Hilt: Live Code Tutorial, Pros and Cons
