|
1 | | -[//]: # (title: Compiler plugins) |
2 | | - |
3 | | -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. |
4 | | - |
5 | | -This page explains the Kotlin compiler plugins available to you and what you can do if none of them suits your use case. |
6 | | - |
7 | | -The Kotlin team maintains the following compiler plugins: |
8 | | - |
9 | | -| Plugin | Description | |
10 | | -|------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------| |
11 | | -| [All-open](all-open-plugin.md) | Automatically makes annotated classes and their members `open` so frameworks can extend them at runtime. | |
12 | | -| [AtomicFU](https://github.com/Kotlin/kotlinx-atomicfu) | Transforms atomic operations into efficient, platform-specific implementations for lock-free concurrency. | |
13 | | -| [DataFrame](https://kotlin.github.io/dataframe/compiler-plugin.html) | Generates typed APIs that let you work with a [`DataFrame`](https://kotlin.github.io/dataframe/home.html) in a safe, Kotlin-friendly way. | |
14 | | -| [`jvm-abi-gen`](https://github.com/JetBrains/kotlin/tree/master/plugins/jvm-abi-gen) | Generates Application Binary Interface (ABI) JARs. | |
15 | | -| [`js-plain-objects`](https://github.com/JetBrains/kotlin/tree/master/plugins/js-plain-objects) | Exposes Kotlin classes as plain JavaScript objects to improve interop with JS tooling and libraries. | |
16 | | -| [kapt](kapt.md) | Runs Java annotation processors on Kotlin code and generates additional source files. | |
17 | | -| [Lombok](lombok.md) | Enables Kotlin code to understand and use code generated by Lombok annotations in Java sources. | |
18 | | -| [`no-arg`](no-arg-plugin.md) | Generates no-argument constructors for annotated classes to support frameworks that require them. | |
19 | | -| [Power-assert](power-assert.md) | Enhances assertion failures by showing detailed values for each part of an expression. | |
20 | | -| [SAM with receiver](sam-with-receiver-plugin.md) | Allows SAM interfaces to use lambdas with receivers for a more DSL-like syntax. | |
21 | | -| [Serialization](serialization.md) | Generates code that serializes and deserializes Kotlin objects without reflection. | |
22 | | - |
23 | | -The Android team at Google maintains: |
24 | | - |
25 | | -| Plugin | Description | |
26 | | -|---------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------| |
27 | | -| [Compose compiler Gradle plugin](https://developer.android.com/develop/ui/compose/compiler) | Integrates the Compose compiler with Gradle to enable declarative UI features and Compose-specific optimizations. | |
28 | | -| [Parcelize plugin](https://plugins.gradle.org/plugin/org.jetbrains.kotlin.plugin.parcelize) | Generates `Parcelable` implementations automatically so you can pass Kotlin objects between Android components. | |
29 | | - |
30 | | -If you need to adapt the compilation process in a way that these plugins don't cover, first check whether you can use the |
31 | | -[Kotlin Symbol Processing (KSP) API](https://kotlinlang.org/docs/ksp-overview.html) or an external linter such as [Android lint](https://developer.android.com/studio/write/lint). |
32 | | -You can browse our [Kotlin Slack](https://slack-chats.kotlinlang.org/c/compiler) or [reach out](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up) |
33 | | -and ask for advice about your use case. |
34 | | - |
35 | | -If you _still_ can't find what you need, you can create a custom compiler plugin. Use this approach only as a last resort, |
36 | | -because the Kotlin compiler plugin API is **unstable**. Maintaining a custom compiler plugin requires significant ongoing |
37 | | -effort, because each new compiler release introduces breaking changes. |
38 | | - |
39 | | -## Custom compiler plugins |
| 1 | +[//]: # (title: Custom compiler plugins) |
40 | 2 |
|
41 | 3 | > The Kotlin compiler plugin API is unstable and introduces breaking changes in every release. |
42 | 4 | > |
43 | 5 | {style="warning"} |
44 | 6 |
|
45 | | -Compiler plugins can influence different stages of the compilation process. |
| 7 | +Compiler plugins hook into the compilation process to analyze or change code while it's being compiled, without modifying |
| 8 | +the compiler itself. For example, they can annotate code or generate new code to make it compatible with other frameworks or APIs. |
| 9 | + |
| 10 | +Before you create your own custom compiler plugin, check the [list of available compiler plugins](compiler-plugins-overview.md) to see if one is already available that suits your use case. |
| 11 | + |
| 12 | +You can also check whether you can use the [Kotlin Symbol Processing (KSP) API](https://kotlinlang.org/docs/ksp-overview.html) or an external linter such as [Android lint](https://developer.android.com/studio/write/lint) to achieve your goals. |
46 | 13 |
|
47 | 14 | {width=300} |
48 | 15 |
|
|
0 commit comments