thanksforallthefish
01/18/2023, 7:34 AMkotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
sourceSets.all {
languageSettings {
progressiveMode = true
}
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17 //see: <https://youtrack.jetbrains.com/issue/IDEA-252328>
freeCompilerArgs = ["-Xjsr305=strict", "-Xemit-jvm-type-annotations", "-opt-in=kotlin.RequiresOptIn"]
}
}
with kotlin 1.8 and groovy build file. sourceSets.all
is suggested to be replaced with source.configureEach
, which seems to work but it deviates from kotlin docs: https://kotlinlang.org/docs/multiplatform-dsl-reference.html#language-settings. moreover, using configureEach
leads to languageSettings
generating a warning as method call is ambiguous
. what is the best approach here?
second confusing (or better, I am not sure what to do) warning is the deprecation of `kotlinOptions`: idea still does not fully support language version, as per https://youtrack.jetbrains.com/issue/IDEA-252328, but the suggested solution requires replacing toolchain with unfortunately no improvements were made yet. The sourceCompatibility and targetCompatibility are safe options for now.
source and target compatibility, and toolchain are mutually exclusive, hence the use of kotlinOptions
. I am mostly concern about upgrading to gradle 8, probably kotlin options will go then, is there another option?gildor
01/18/2023, 7:38 AMconfigureEach
instead of all
(but not sure about what is the issue with languageSettings, in general all/configureEach should be the samethanksforallthefish
01/18/2023, 7:41 AMall
intellij warns of No candidates found for method call languageSettings.
, in the end it’s just intellij but was looking for an option that would make ide happy toothanksforallthefish
01/18/2023, 7:42 AMgildor
01/18/2023, 7:42 AMVampire
01/18/2023, 7:47 AM-all
distribution is helpful to improve developer life, but really only while editing the file.
But yeah, Kotlin DSL does not only have "a bit" better IDE support, but amazingly better IDE support. :-)Vampire
01/18/2023, 7:54 AMVampire
01/18/2023, 7:55 AMkotlinOptions
, as far as I remember you should use something like
compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
insteadthanksforallthefish
01/18/2023, 8:07 AMAlso upgrading Gradle has nothing to do with your problem, Kotlin Options are from the Kotlin Gradle plugin so independent from Gradle version.ah, fair point, thanks for the explanation