Skip to content

Commit c3710bd

Browse files
TapchicomaSpace Team
authored andcommitted
[Gradle] Adjust jvm target diagnostic message
Do not mention that this diagnostic level becomes error in Gradle 8.0 if the build is using Gradle 8.+ versions. Some users or plugin may downgrade diagnostic level back to warning, and this line is misleading for the users. ^KT-80096 Verification Pending
1 parent 9ad0d48 commit c3710bd

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/diagnostics/KotlinToolingDiagnostics.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,11 +807,19 @@ internal object KotlinToolingDiagnostics {
807807
jvmTarget: String,
808808
severity: ToolingDiagnostic.Severity,
809809
) = build(severity = severity) {
810+
val gradleErrorMessage = if (severity == WARNING &&
811+
GradleVersion.current() < GradleVersion.version("8.0")
812+
) {
813+
"This will become an error in Gradle 8.0."
814+
} else {
815+
""
816+
}
817+
810818
title("Inconsistent JVM Target Compatibility Between Java and Kotlin Tasks")
811819
.description {
812820
"""
813821
Inconsistent JVM-target compatibility detected for tasks '$javaTaskName' ($targetCompatibility) and '$kotlinTaskName' ($jvmTarget).
814-
${if (severity == WARNING) "This will become an error in Gradle 8.0." else ""}
822+
$gradleErrorMessage
815823
""".trimIndent()
816824
}
817825
.solution {

libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/tasks/DefaultKotlinJavaToolchain.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ internal abstract class DefaultKotlinJavaToolchain @Inject constructor(
229229
else -> javaVersion.toString()
230230
}
231231

232-
// Update to the latest JDK LTS once it is released and Kotlin has JVM target with this version
232+
// Update to the latest JDK LTS once it is released, and Kotlin has a JVM target with this version,
233+
// plus the minimal supported Gradle version itself supports it
233234
return if (javaVersion > JavaVersion.VERSION_17) {
234235
try {
235236
JvmTarget.fromTarget(normalizedVersion)

0 commit comments

Comments
 (0)