Skip to content

Use non-deprecated Kotlin DSL for Kotlin compile options #1495

@CXwudi

Description

@CXwudi

In recent version of Kotlin Gradle Plugin, tasks.withType<KotlinCompile>.kotlinOptions is marked as deprecated

image

A better DSL is:

import org.jetbrains.kotlin.gradle.dsl.JvmTarget

kotlin {
  compilerOptions {
    freeCompilerArgs = freeCompilerArgs.get() + listOf("-Xjsr305=strict")
    jvmTarget = JvmTarget.JVM_21
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions