diff --git a/docs/topics/compiler-reference.md b/docs/topics/compiler-reference.md index 33b8c876cd2..9afe010708b 100644 --- a/docs/topics/compiler-reference.md +++ b/docs/topics/compiler-reference.md @@ -236,6 +236,40 @@ Allows using the `returnsNotNull()` function in contracts to assume a non-null r Allows using the `holdsIn` keyword in contracts to assume that a boolean condition is `true` inside a lambda. +### -Xcompiler-plugin-order={plugin.before>plugin.after} + +Configure the running order of compiler plugins. Place the compiler plugin you want to run first on the left side of the +`>`, and the compiler plugin you want to run second on the right. + +You can define multiple ordering rules. For example: + +```bash +kotlinc -Xcompiler-plugin-order=plugin.first>plugin.middle +kotlinc -Xcompiler-plugin-order=plugin.middle>plugin.last +``` + +This results in the following running order: `plugin.first`, then `plugin.middle`, and finally `plugin.last`. +If a compiler plugin isn't present, the corresponding rule is ignored. + +You can configure the following plugins by their IDs: + +| Compiler plugin | Plugin ID | +|-----------------------------|--------------------------------------------| +| `all-open`, `kotlin-spring` | `org.jetbrains.kotlin.allopen` | +| AtomicFU | `org.jetbrains.kotlinx.atomicfu` | +| Compose | `androidx.compose.compiler.plugins.kotlin` | +| `js-plain-objects` | `org.jetbrains.kotlinx.jspo` | +| `jvm-abi-gen` | `org.jetbrains.kotlin.jvm.abi` | +| kapt | `org.jetbrains.kotlin.kapt3` | +| Lombok | `org.jetbrains.kotlin.lombok` | +| `no-arg`, `kotlin-jpa` | `org.jetbrains.kotlin.noarg` | +| Parcelize | `org.jetbrains.kotlin.parcelize` | +| Power-assert | `org.jetbrains.kotlin.powerassert` | +| SAM with receiver | `org.jetbrains.kotlin.samWithReceiver` | +| Serialization | `org.jetbrains.kotlinx.serialization` | + +This running order controls only the backend of compiler plugins and not the frontend. + ## Kotlin/JVM compiler options The Kotlin compiler for JVM compiles Kotlin source files into Java class files. diff --git a/docs/topics/k2-compiler-migration-guide.md b/docs/topics/k2-compiler-migration-guide.md index d4879bd37bb..9d6b82a9bec 100644 --- a/docs/topics/k2-compiler-migration-guide.md +++ b/docs/topics/k2-compiler-migration-guide.md @@ -1295,6 +1295,7 @@ Currently, the Kotlin K2 compiler supports the following Kotlin compiler plugins * [Lombok](lombok.md) * [`no-arg`](no-arg-plugin.md) * [Parcelize](https://plugins.gradle.org/plugin/org.jetbrains.kotlin.plugin.parcelize) +* [Power-assert](power-assert.md) * [SAM with receiver](sam-with-receiver-plugin.md) * [Serialization](serialization.md)