Use of deprecated 'kotlinOptions' DSL
Reports usages of the deprecated kotlinOptions DSL in Gradle .kts build scripts.
The kotlinOptions DSL was deprecated in Kotlin 2.0. The inspection helps migrate from kotlinOptions to compilerOptions. It also changes the types of several options that use the new types instead of the String type.
Example for the KotlinCompile task:
val compileKotlin: KotlinCompile by tasks
compileKotlin.kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = listOf("-module-name", "my_module_name")
apiVersion = "1.9"
}
//OR
tasks.withType {
kotlinOptions {
freeCompilerArgs += listOf("-module-name", "my_module_name")
}
}
The inspection also adds imports for options with changed types:
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
...
val compileKotlin: KotlinCompile by tasks
compileKotlin.compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
freeCompilerArgs.set(listOf("-module-name", "my_module_name"))
apiVersion.set(KotlinVersion.KOTLIN_1_9)
}
Example for the Kotlin2JsCompile task:
val compileKotlin: Kotlin2JsCompile by tasks
compileKotlin.kotlinOptions {
moduleKind = "commonjs"
sourceMapEmbedSources = "inlining"
sourceMapNamesPolicy = "fully-qualified-names"
main = "noCall"
}
After the inspection is applied:
import org.jetbrains.kotlin.gradle.dsl.JsMainFunctionExecutionMode
import org.jetbrains.kotlin.gradle.dsl.JsModuleKind
import org.jetbrains.kotlin.gradle.dsl.JsSourceMapEmbedMode
import org.jetbrains.kotlin.gradle.dsl.JsSourceMapNamesPolicy
...
val compileKotlin: Kotlin2JsCompile by tasks
compileKotlin.compilerOptions {
moduleKind.set(JsModuleKind.MODULE_COMMONJS)
sourceMapEmbedSources.set(JsSourceMapEmbedMode.SOURCE_MAP_SOURCE_CONTENT_INLINING)
sourceMapNamesPolicy.set(JsSourceMapNamesPolicy.SOURCE_MAP_NAMES_POLICY_FQ_NAMES)
main.set(JsMainFunctionExecutionMode.NO_CALL)
}
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
KotlinOptionsToCompilerOptions
- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
Inspection ID: KotlinOptionsToCompilerOptions
Suppressing Inspection
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
//noinspection KotlinOptionsToCompilerOptions
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Last modified: 03 December 2025