I’m seeing this warning emitted from KGP in a proj...
# eap
z
I’m seeing this warning emitted from KGP in a project that does appear to set the JVM target to 11, wondering if this is a bug I should file or something I’m missing
> Task slack plugincompileTestKotlin
‘compileTestJava’ task (current target is 11) and ‘compileTestKotlin’ task (current target is 1.8) jvm target compatibility should be set to the same Java version.
By default will become an error since Gradle 8.0+! Read more: https://kotl.in/gradle/jvm/target-validation
Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain
Repro: https://github.com/slackhq/slack-gradle-plugin/pull/166 CC @tapchicoma
1
a
That’s an effect of you applying the
kotlin-dsl
plugin. It reconfigures some properties in `afterEvaluate`: https://github.com/gradle/gradle/blob/daece9dbc5b79370cc8e4fd6fe4b2cd400e150a8/sub[…]n/org/gradle/kotlin/dsl/plugins/dsl/KotlinDslCompilerPlugins.kt
It seems you can configure the value that the plugin is setting:
Copy code
kotlinDslPluginOptions {
  jvmTarget.set(...)
}
but since Gradle 8.0 (at least I see such code in
master
of Gradle) it will be automatically picked up from a JVM toolchain
t
@Alexander.Likhachev you've told about another issue - not related to posted here 🙂
Let me check the repro
ah no, @Alexander.Likhachev is right - it is issue with
kotlin-dsl
plugin setting in
afterEvaluate
jvmTarget
to
1.8
so KGP is fine
also note that since KGP 1.8 this check is also running when Java sources is empty - so you see such warning
z
wait why would it be setting the jvmTarget of KotlinCompile lower? Shouldn’t kotlin-dsl just apply to the buildscript itself?
t
check this link from Alexander - it applies it to every
KotlinCompile
task in project.
z
such a frustrating situation with gradle