From 15b9825105dde78bf65a53b86987cbca542b5e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Basl=C3=A9?= Date: Fri, 1 Oct 2021 17:32:20 +0200 Subject: [PATCH] Fix Module was compiled with an incompatible version of Kotlin (#2795) While upgrading to Gradle 7.2, the version of the Kotlin gradle plugin was also upgraded to 1.5.31 to ensure plugin compatibility. What was overlooked is that this means an upgrade of the Kotlin language level, which is undesirable in a patch release. This is made visible in donwstream projects still relying on Kotlin 1.3 with the following message for instance: ``` Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.16. ``` This commit fixes the situation by enforcing Kotlin version 1.3 for both `apiVersion` and `languageVersion`. It results in metadata at version 1.1.18, but local tests show that it should this time be compatible with expected version 1.1.16. Fixes #2793. --- build.gradle | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 6c004f3ec4..e33e355098 100644 --- a/build.gradle +++ b/build.gradle @@ -257,12 +257,20 @@ configure(subprojects) { p -> if (p.plugins.hasPlugin("kotlin")) { println "Applying Kotlin conventions to ${p.name}" compileKotlin { - kotlinOptions.jvmTarget = "1.8" - kotlinOptions.freeCompilerArgs = ["-Xjsr305=strict"] + kotlinOptions { + jvmTarget = "1.8" + freeCompilerArgs = ["-Xjsr305=strict"] + languageVersion = "1.3" //TODO kotlin languageVersion 1.3 is now deprecated + apiVersion = "1.3" + } } compileTestKotlin { - kotlinOptions.jvmTarget = "1.8" - kotlinOptions.freeCompilerArgs = ["-Xjsr305=strict"] + kotlinOptions { + jvmTarget = "1.8" + freeCompilerArgs = ["-Xjsr305=strict"] + languageVersion = "1.3" //TODO kotlin languageVersion 1.3 is now deprecated + apiVersion = "1.3" + } } } }