Kotlin Help

Compiler execution strategy

The Kotlin compiler execution strategy defines where the Kotlin compiler runs. Build tools such as Gradle or Maven configure the strategy.

There are two compiler execution strategies:

Strategy

Where the Kotlin compiler runs

Other characteristics and notes

Kotlin daemon

Inside its own daemon process

The default and fastest strategy in Gradle and Maven. The daemon process can be shared between different build system processes and multiple parallel compilations.

In process

Inside the build tool's process

The simplest strategy from the perspective of memory management, but it's less isolated from other logic running in the same process because it shares state, such as JVM system properties.

Configure in Gradle

You can define the Kotlin compiler execution strategy using one of the following properties:

  • The kotlin.compiler.execution.strategy Gradle property.

  • The compilerExecutionStrategy compile task property.

Use the Gradle property

The possible values for the kotlin.compiler.execution.strategy property are:

  • daemon (default)

  • in-process

Set the kotlin.compiler.execution.strategy property in gradle.properties:

kotlin.compiler.execution.strategy=in-process

Use the compile task property

The compilerExecutionStrategy task property takes priority over the kotlin.compiler.execution.strategy Gradle property.

The possible values for the compilerExecutionStrategy task property are:

Set the compilerExecutionStrategy task property in your build scripts:

import org.jetbrains.kotlin.gradle.tasks.CompileUsingKotlinDaemon import org.jetbrains.kotlin.gradle.tasks.KotlinCompilerExecutionStrategy // ... tasks.withType<CompileUsingKotlinDaemon>().configureEach { compilerExecutionStrategy.set(KotlinCompilerExecutionStrategy.IN_PROCESS) }
import org.jetbrains.kotlin.gradle.tasks.CompileUsingKotlinDaemon import org.jetbrains.kotlin.gradle.tasks.KotlinCompilerExecutionStrategy // ... tasks.withType(CompileUsingKotlinDaemon) .configureEach { compilerExecutionStrategy = KotlinCompilerExecutionStrategy.IN_PROCESS }

Fallback strategy

If communication with the Kotlin daemon fails, the compiler falls back to the "In process" strategy.

When this fallback happens, Gradle prints the following warning in the build output:

Failed to compile with Kotlin daemon: java.lang.RuntimeException: Could not connect to Kotlin compile daemon [exception stacktrace] Using fallback strategy: Compile without Kotlin daemon Try ./gradlew --stop if this issue persists.

A silent fallback can consume a lot of system resources or lead to non-deterministic builds. For more information, see this YouTrack issue.

To prevent fallback, use the kotlin.daemon.useFallbackStrategy Gradle property. The default value is true. When set to false, builds fail if there are problems with the daemon's startup or communication. Declare this property in gradle.properties:

kotlin.daemon.useFallbackStrategy=false

There is also a useDaemonFallbackStrategy property in Kotlin compile tasks. If you use both properties, the useDaemonFallbackStrategy property takes priority.

tasks { compileKotlin { useDaemonFallbackStrategy.set(false) } }
tasks.named("compileKotlin").configure { useDaemonFallbackStrategy = false }

If there is not enough memory to run the compilation, the logs show a related message.

Configure in Maven

By default, Maven uses the Kotlin daemon compiler execution strategy. To switch to the "in process" strategy, set the following property in your pom.xml file:

<properties> <kotlin.compiler.daemon>false</kotlin.compiler.daemon> </properties>
16 March 2026