Writing Your First Kotlin Compiler Plugin
summary
Shows how to build and publish a real Kotlin compiler plugin as two modules: a Gradle sub-plugin wrapper and a Kotlin module implementing a command line processor and component registrar. Uses the Kotlin compiler embeddable API, registers a ClassBuilderInterceptorExtension, and emits JVM bytecode via objectweb ASM to inject entry/exit logging. The demo modifies a prime calculator, traces the 20,000th prime, prints parameter values and elapsed time (~6–7s), and shows packaging for Maven/JCenter so the plugin can be applied from Gradle.
AI-written summary · about
chapters (7)
- 0:00Start
- 2:22Why write compiler plugins?
- 2:56Why NOT write compiler plugins?
- 4:00Examples of compiler plugins
- 6:21Plugin Architecture
- 26:49What does bytecode look like?
- 41:42Resources
related talks
36mWriting a Kotlin Compiler Plugin
36mMeta-programming with Kotlin compiler plugins
01h 13mThe Magic of Kotlin Compiler Extensions
26mBuild your own compiler with KSP
45mCompiler plugins: modifying and analyzing Compose
43mCrash Course on the Kotlin Compiler
35mHow to write Gradle plugins (in Kotlin)
37mBuilding a Kotlin Compiler Plugin for Compose Insights
