Compiler plugins
Compiler plugins hook into the compilation process to analyze or change code while it's being compiled, without modifying the compiler itself. For example, they can annotate code or generate new code to make it compatible with other frameworks or APIs.
This page explains the Kotlin compiler plugins available to you and what you can do if none of them suits your use case.
The Kotlin team maintains the following compiler plugins:
Plugin | Description |
|---|---|
Automatically makes annotated classes and their members | |
Transforms atomic operations into efficient, platform-specific implementations for lock-free concurrency. | |
Generates typed APIs that let you work with a | |
Generates Application Binary Interface (ABI) JARs. | |
Exposes Kotlin classes as plain JavaScript objects to improve interop with JS tooling and libraries. | |
Runs Java annotation processors on Kotlin code and generates additional source files. | |
Enables Kotlin code to understand and use code generated by Lombok annotations in Java sources. | |
Generates no-argument constructors for annotated classes to support frameworks that require them. | |
Enhances assertion failures by showing detailed values for each part of an expression. | |
Allows SAM interfaces to use lambdas with receivers for a more DSL-like syntax. | |
Generates code that serializes and deserializes Kotlin objects without reflection. |
The Android team at Google maintains:
Plugin | Description |
|---|---|
Integrates the Compose compiler with Gradle to enable declarative UI features and Compose-specific optimizations. | |
Generates |
If you need to adapt the compilation process in a way that these plugins don't cover, first check whether you can use the Kotlin Symbol Processing (KSP) API or an external linter such as Android lint. You can browse our Kotlin Slack or reach out and ask for advice about your use case.
If you still can't find what you need, you can create a custom compiler plugin. Use this approach only as a last resort, because the Kotlin compiler plugin API is unstable. If you create a custom compiler plugin, you need to invest significant ongoing effort to maintain it, since each new compiler release introduces breaking changes.