JetBrains/kotlin
Compiler plugins
Active contributors: Dmitriy Novozhilov, Andrei Shikov, Leonid Startsev
The plugins/ directory hosts compiler plugins — extensions that hook into FIR (the K2 frontend) and/or IR (the backend representation) to add language features without changing the compiler core. The largest are widely used by Kotlin programmers: Compose, kotlinx.serialization, kapt, parcelize, allopen, lombok, atomicfu, power-assert.
This page is the index. Each plugin has its own short page below; small plugins are batched.
Pages in this section
- Compose —
plugins/compose/ - kotlinx.serialization —
plugins/kotlinx-serialization/ - kapt —
plugins/kapt/ - Parcelize —
plugins/parcelize/ - Spring/JPA helpers (allopen, noarg, sam-with-receiver, lombok) —
plugins/{allopen,noarg,sam-with-receiver,lombok}/ - Other plugins — assign-plugin, atomicfu, jvm-abi-gen, js-plain-objects, power-assert, scripting, kotlin-dataframe, plugin-sandbox
Top-level layout
plugins/
├── allopen/ Open declarations matching annotations (Spring, JPA)
├── assign-plugin/ Custom assignment-operator overloading
├── atomicfu/ Atomic field updaters (kotlinx.atomicfu compiler plugin)
├── compose/ Jetpack Compose / Compose Multiplatform plugin
├── js-plain-objects/ "Plain JS objects" support
├── jvm-abi-gen/ Stripped-ABI jar generator for incremental builds
├── kapt/ Kotlin Annotation Processing Tool
├── kotlin-dataframe/ DataFrame's compile-time schema generation
├── kotlinx-serialization/ kotlinx.serialization plugin
├── lombok/ Lombok interop on Kotlin sources
├── noarg/ Synthesize no-arg constructors (JPA)
├── parcelize/ Android Parcelable generation
├── plugin-sandbox/ A "sandbox" plugin used as a learning example/test bed
├── plugins-interactions-testing/ Tests that exercise multiple plugins together
├── power-assert/ Detailed assertion failure messages
├── sam-with-receiver/ SAM conversion with extension receiver
├── scripting/ Compiler plugin behind libraries/scripting/
└── test-plugins/ Plugins used purely as test fixturesPlugin extension points
Compiler plugins hook in via two main extension surfaces:
| Surface | Where it's defined | What it does |
|---|---|---|
| FIR extensions | compiler/fir/plugin-utils/ and the K2 FirExtension API |
Add new top-level declarations, modify resolved declarations, supply types for synthesized members. |
| IR generation | compiler/plugin-api/ and the IrGenerationExtension interface |
Walk and rewrite IR after frontend resolution. |
Older plugins (kapt, parcelize, allopen) had K1 paths. Most have been updated to ship K2 (FIR-based) implementations alongside the K1 ones.
Build and ship
Each plugin is built as two artifacts (typically):
- A compiler plugin jar — loaded by
kotlincvia-Xplugin=.... - A runtime/companion jar — supplies the runtime types the generated code references.
KGP and the Maven plugin expose user-friendly DSL/configuration for each, hiding the -Xplugin= mechanics.
How plugins integrate with KGP
KGP-side modules wrap compiler plugins in Gradle DSLs:
libraries/tools/kotlin-allopen/(DSL) ↔plugins/allopen/(compiler plugin)libraries/tools/kotlin-noarg/↔plugins/noarg/libraries/tools/kotlin-serialization/↔plugins/kotlinx-serialization/libraries/tools/kotlin-compose-compiler/↔plugins/compose/libraries/tools/kotlin-power-assert/↔plugins/power-assert/libraries/tools/kotlin-lombok/↔plugins/lombok/libraries/tools/kotlin-dataframe/↔plugins/kotlin-dataframe/libraries/tools/kotlin-assignment/↔plugins/assign-plugin/libraries/tools/kotlin-sam-with-receiver/↔plugins/sam-with-receiver/libraries/tools/atomicfu/↔plugins/atomicfu/
(Maven counterparts exist for most — see Maven plugin.)
Where to start
Read the plugin-extension-API in compiler/plugin-api/ plus the FIR extension API in compiler/fir/plugin-utils/. Browse plugins/plugin-sandbox/ for a teaching example. To prototype a new plugin, copy plugins/plugin-sandbox/ and adapt it.
For specific plugins: each has its own page; pick from the list above.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.