# Configuring Kotlin Support

> For the complete documentation index, see [llms.txt](https://plugins.jetbrains.com/docs/intellij/llms.txt).

This page describes developing plugins using the [Kotlin](https://kotlinlang.org) programming language.

> **Tip: Operating on Kotlin code**
> To implement a plugin operating on Kotlin code ([PSI](psi.html)) in the IDE, see [Kotlin Plugin](idea.html#kotlin-plugin).

## Advantages of Developing a Plugin in Kotlin

Using Kotlin to write plugins for the IntelliJ Platform is very similar to writing plugins in Java. Existing Java classes can be converted to their Kotlin equivalents by using the [J2K converter](https://kotlinlang.org/docs/mixing-java-kotlin-intellij.html#converting-an-existing-java-file-to-kotlin-with-j2k) (part of the Kotlin plugin).

In addition to [null safety](https://kotlinlang.org/docs/null-safety.html), [type-safe builders](https://kotlinlang.org/docs/type-safe-builders.html), and [Kotlin Coroutines](kotlin-coroutines.html) the Kotlin language offers many convenient features for plugin development, which make plugins easier to read and simpler to maintain. Much like [Kotlin for Android](https://kotlinlang.org/docs/android-overview.html), the IntelliJ Platform makes extensive use of callbacks, which are straightforward to express as [lambdas](https://kotlinlang.org/docs/lambdas.html) in Kotlin.

Kotlin classes can be mixed in a project with existing Java code. This might come in handy when certain APIs require the use of mentioned Kotlin Coroutines.

### Adding Extensions

Likewise, it is possible to customize the behavior of internal classes in the IntelliJ Platform using [extensions](https://kotlinlang.org/docs/extensions.html). For example, it is common practice to [guard logging statements](https://www.slf4j.org/faq.html#logging_performance) to avoid the cost of parameter construction, leading to the following ceremony when using the log:

```JAVA
if (logger.isDebugEnabled()) {
  logger.debug("..."+expensiveComputation());
}
```

Kotlin achieves the same result more succinctly with the following extension method:

```KOTLIN
inline fun Logger.debug(lazyMessage: () -> String) {
  if (isDebugEnabled) {
    debug(lazyMessage())
  }
}
```

Now, write directly:

```KOTLIN
logger.debug { "..." + expensiveComputation() }
```

to receive all the benefits of lightweight logging while reducing the code verbosity.

With practice, it becomes easier to recognize many idioms in the IntelliJ Platform that can be simplified with Kotlin.

### UI Forms in Kotlin

The IntelliJ Platform provides a [type-safe DSL](kotlin-ui-dsl-version-2.html) to build UI forms declaratively.

> **Tip:**
> Using UI Designer plugin with Kotlin is [not supported](https://youtrack.jetbrains.com/issue/KTIJ-791).

### Kotlin Coroutines

[Kotlin Coroutines](kotlin-coroutines.html) are a lightweight and convenient alternative to threads with many [advantages](kotlin-coroutines.html#coroutines-advantages).

## Adding Kotlin Support

> **Tip:**
> [IDE Plugin generator](creating-plugin-project.html#create-ide-plugin) adds the Kotlin support by default, and no additional configuration is required in most cases.

IntelliJ IDEA bundles the necessary Kotlin IDE plugin, requiring no further configuration. For detailed instructions, refer to the [Kotlin documentation](https://kotlinlang.org/docs/getting-started.html).

Using Kotlin 2.x is recommended for plugins targeting 2024.3 or later and required for 2025.1 or later.

### Kotlin Gradle Plugin

Adding Kotlin source files compilation support to a Gradle-based project requires adding and configuring the [Kotlin JVM Gradle plugin](https://kotlinlang.org/docs/gradle.html#targeting-the-jvm).

###  Kotlin Standard Library (`stdlib`) 

A dependency on the standard library `stdlib` is added automatically ([API Docs](https://kotlinlang.org/api/latest/jvm/stdlib/)). In nearly all cases, it is not necessary to include it in the plugin distribution as the platform already bundles it.

To opt out, add this line in `gradle.properties`:

```PROPERTIES
kotlin.stdlib.default.dependency = false
```

To bundle `stdlib` in the plugin distribution, set the property to `true` explicitly.

#### Gradle Check

The presence of this Gradle property is checked with the corresponding Gradle task:

IntelliJ Platform Gradle Plugin (2.x):

[verifyPlugin](tools-intellij-platform-gradle-plugin-tasks.html#verifyPluginProjectConfiguration) task

Gradle IntelliJ Plugin (1.x):

[verifyPluginConfiguration](tools-gradle-intellij-plugin.html#tasks-verifypluginconfiguration) task

If the property is not present, a warning will be reported during the plugin configuration verification.

####  `stdlib` – Miscellaneous 

If a plugin supports [multiple platform versions](build-number-ranges.html), it must either target the lowest bundled `stdlib` version (see [table below](#bundled-stdlib-versions)) or the specific version must be [provided in plugin distribution](plugin-content.html#plugin-with-dependencies).

See [Dependency on the standard library](https://kotlinlang.org/docs/gradle.html#dependency-on-the-standard-library) for more details.

> **Tip: Adding stdlib in tests**
> To add the Kotlin Standard Library to the test project dependencies, see the [How to test a JVM language?](testing-faq.html#how-to-test-a-jvm-language) section.

####  Bundled `stdlib` Versions 

| IntelliJ Platform version (latest update) | Bundled `stdlib` version |
| --- | --- |
| 2026.3 | 2.4.21-RC |
| 2026.2 | 2.4.0 |
| 2026.1 | 2.3.20 |
| 2025.3 | 2.2.20 |
| 2025.2 | 2.1.20 |
| 2025.1 | 2.1.10 |

#### Earlier Versions

| IntelliJ Platform version (latest update) | Bundled stdlib version |
| --- | --- |
| 2024.3 | 2.0.21 |
| 2024.2 | 1.9.24 |
| 2024.1 | 1.9.22 |
| 2023.3 | 1.9.21 |
| 2023.2 | 1.8.20 |
| 2023.1 | 1.8.0 |
| 2022.3 | 1.7.22 |
| 2022.2 | 1.6.21 |
| 2022.1 | 1.6.10 |

See [here](https://www.jetbrains.com/legal/third-party-software/) for earlier versions.

###  Kotlin Coroutines Libraries (`kotlinx.coroutines`) 

> **Warning: Use Bundled Library**
> Plugins must always use the bundled library from the target IDE and not provide their own version.

Make sure it is not added via transitive dependencies, see [View and Debug Dependencies](https://docs.gradle.org/current/userguide/viewing_debugging_dependencies.html) in the Gradle user guide.

See [Kotlin Coroutines](kotlin-coroutines.html) on how to use them in plugins.

####  Bundled `kotlinx-coroutines` Versions 

| IntelliJ Platform version (latest update) | Bundled `kotlinx-coroutines` version |
| --- | --- |
| 2026.3 | 1.11.0-intellij-1 |
| 2026.2 | 1.10.2-intellij-1 |
| 2026.1 | 1.10.2-intellij-1 |
| 2025.3 | 1.10.1-intellij-5 |
| 2025.2 | 1.10.1-intellij-4 |
| 2025.1 | 1.8.0-intellij-13 |
| 2024.3 | 1.8.0-intellij-11 |
| 2024.2 | 1.8.0-intellij-9 (*) |
| 2024.1 | 1.7.3 |

(*) Since 2024.2, a custom [fork](https://github.com/JetBrains/intellij-deps-kotlinx.coroutines) with additional patches is bundled.

### Other Bundled Kotlin Libraries

In general, it is strongly advised to always use the bundled library version.

See [Third-Party Software and Licenses](https://www.jetbrains.com/legal/third-party-software/) for an overview of all bundled libraries.

### Incremental compilation

The Kotlin Gradle plugin supports [incremental compilation](https://kotlinlang.org/docs/gradle-compilation-and-caches.html#incremental-compilation), which allows tracking changes in the source files, so the compiler handles only updated code.

Kotlin 1.9.0 and later:

No action is required.

Remove the additional `kotlin.incremental.useClasspathSnapshot=false` property in `gradle.properties` if present.

Kotlin 1.8.20:

> **Tip:**
> Consider using Kotlin 1.9.0 or later where this issue has been resolved.

Kotlin `1.8.20` has a [new incremental compilation approach](https://kotlinlang.org/docs/gradle-compilation-and-caches.html#a-new-approach-to-incremental-compilation) which is enabled by default. Unfortunately, it is not compatible with the IntelliJ Platform when reading large JAR files (like `app.jar` or `3rd-party-rt.jar`), leading to an `Out of Memory` exception:

```TEXT
Execution failed for task ':compileKotlin'.
> Failed to transform app.jar to match attributes {artifactType=classpath-entry-snapshot, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
   > Execution failed for ClasspathEntrySnapshotTransform: .../lib/app.jar.
      > Java heap space
```

To avoid this exception, add the following line to `gradle.properties`:

```PROPERTIES
kotlin.incremental.useClasspathSnapshot=false
```

## Plugin Implementation Notes

###  Do not use `object` but `class` 

Plugins may use [Kotlin classes](https://kotlinlang.org/docs/classes.html) (`class` keyword) to implement declarations in the [plugin configuration file](plugin-configuration-file.html). When registering an [extension](plugin-extensions.html), the platform uses a dependency injection framework to instantiate these classes at runtime. For this reason, plugins must not use [Kotlin objects](https://kotlinlang.org/docs/object-declarations.html#object-declarations-overview) (`object` keyword) to implement any `[plugin.xml](plugin-configuration-file.html)` declarations. Managing the lifecycle of extensions is the platform's responsibility, and instantiating these classes as Kotlin singletons may cause issues.

A notable exception is [FileType](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/core-api/src/com/intellij/openapi/fileTypes/FileType.java) ([com.intellij.fileType](https://jb.gg/ipe?extensions=com.intellij.fileType) extension point ), see also the inspection descriptions below.

Problems are highlighted via these inspections (2023.2):

* Plugin DevKit | Code | Kotlin object registered as extension for Kotlin code

* Plugin DevKit | Plugin descriptor | Extension class is a Kotlin object for `plugin.xml`

###  Do not use `companion object` in extensions 

A Kotlin `companion object` is always created once its containing class is loaded, and [extension point implementations](plugin-extensions.html) are supposed to be cheap to create. To avoid unnecessary classloading (and thus slowdown in IDE startup), `companion object` in extensions must only contain simple constants or [logger](ide-infrastructure.html#logging). Anything else must be a top-level declaration or stored in an `object`.

Use inspection Plugin DevKit | Code | Companion object in extensions to highlight such problems (2023.3).

## Example Plugins Implemented in Kotlin

Browse all [open-source Kotlin plugins](https://jb.gg/ipe?language=kotlin) built on the IntelliJ Platform.

