Configure Kotlin compiler for your Maven project
The kotlin-maven-plugin allows you to configure the Kotlin compiler for your Maven projects. You can specify compiler options, choose an execution strategy, and enable incremental compilation.
Specify compiler options
You can specify additional options and arguments for the compiler as elements in the <configuration> section of the Kotlin Maven plugin node:
Many of the options can also be configured through properties:
The following attributes are supported:
Attributes specific to JVM
Name | Property name | Description | Possible values | Default value |
|---|---|---|---|---|
| Generate no warnings | true, false | false | |
|
| Provide source compatibility with the specified version of Kotlin | "1.9", "2.0", "2.1", "2.2", "2.3", "2.4" (EXPERIMENTAL) | |
|
| Allow using declarations only from the specified version of bundled libraries | "1.9", "2.0", "2.1", "2.2", "2.3", "2.4" (EXPERIMENTAL) | |
| The directories containing the source files to compile | The project source roots | ||
| Enabled compiler plugins | [] | ||
| Options for compiler plugins | [] | ||
| Additional compiler arguments | [] | ||
|
| Target version of the generated JVM bytecode | "1.8", "9", "10", ..., "25" | "1.8" |
|
| Include a custom JDK from the specified location into the classpath instead of the default JAVA_HOME |
Choose execution strategy
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:
For more information about the different strategies, see Compiler execution strategy.
Enable incremental compilation
To make your builds faster, you can enable incremental compilation by adding the kotlin.compiler.incremental property:
Alternatively, run your build with the -Dkotlin.compiler.incremental=true option.