kqr
11/16/2023, 9:38 AMtasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict", "-Xallow-any-scripts-in-source-roots")
}
}
and
kotlin {
compilerOptions {
freeCompilerArgs.add("-Xjsr305=strict")
freeCompilerArgs.add("-Xallow-any-scripts-in-source-roots")
}
}
or to be more precise why the latter one does not work ?:)mateusz.kwiecinski
11/16/2023, 9:39 AMhetask input and thekotlinOptionstask DSL are in a support mode and will be deprecated in upcoming releases.kotlinOptions{...}
mateusz.kwiecinski
11/16/2023, 9:41 AMcompilerOptions instead of kotlinOptions on the tasks directly work?kqr
11/16/2023, 9:42 AM-Xallow-any-scripts-in-source-roots is respected in the first onemateusz.kwiecinski
11/16/2023, 9:49 AMprintln what are tasks's compilerOptions.freeCompilerArgs in both scenarios and compare them 🙂 They both should work the same way.
I can't play with your source code, but maybe you have custom kotlinCompile tasks that are not configured by KGP, maybe the later scenario has some extra arguments in the freeCompilerArgs already, which are overwritten in the first scenario (by freeCompilerArgs = listOf()kqr
11/16/2023, 9:59 AMtasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
}
}tapchicoma
11/16/2023, 11:00 AMtapchicoma
11/16/2023, 11:00 AMfreeCompilerArgs - better to use +=tapchicoma
11/16/2023, 11:02 AMkotlinOptions - they are semi-deprecated and we should add normal @Deprecated annotation in 2.0kqr
11/17/2023, 9:45 AMtasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
jvmTarget = "17"
}
}
in my root build file in allprojects block. How can I use kotlin there? or how can I achieve globally set compile options that can be fine tuned in subprojects? right now this will apparently override anything I set in subprojects with kotlin even when using +=tapchicoma
11/17/2023, 10:30 AMplugins {
id("org.jetbrains.kotlin.jvm")
}
allprojects {
kotlin.compilerOptions {
// common configuration for compiler args
}
}kqr
11/17/2023, 2:23 PMtasks.withType<KotlinCompile> {
compilerOptions {
freeCompilerArgs.add("-Xjsr305=strict")
jvmTarget.set(JvmTarget.JVM_17)
}
}