You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Build] Align Gradle-related modules stdlib with the API version
This change also slightly reworks API and language version configuration. Instead of limiting them for all Kotlin compile tasks in the project, configure them granularly, only for "main" or other published parts. This allows to use fresh Kotlin for tests.
Also fixes warnings in test code related to LV bump there.
^KT-61911 Fixed
Copy file name to clipboardExpand all lines: libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/PropertiesBuildServiceTest.kt
-1
Original file line number
Diff line number
Diff line change
@@ -102,7 +102,6 @@ class PropertiesBuildServiceTest {
@@ -546,37 +558,65 @@ private fun Project.commonVariantAttributes(): Action<Configuration> = Action<Co
546
558
}
547
559
}
548
560
549
-
fun Project.configureKotlinCompileTasksGradleCompatibility() {
550
-
tasks.withType<KotlinCompile>().configureEach {
551
-
compilerOptions {
552
-
if (!kotlinBuildProperties.isInJpsBuildIdeaSync) {
553
-
// check https://docs.gradle.org/current/userguide/compatibility.html#kotlin for Kotlin-Gradle versions matrix
554
-
@Suppress("DEPRECATION", "DEPRECATION_ERROR") // we can't use language version greater than 1.8 as our minimal supported Gradle 7.6 embeds Kotlin 1.7.10
555
-
languageVersion.set(KotlinVersion.KOTLIN_1_7)
556
-
@Suppress("DEPRECATION", "DEPRECATION_ERROR") // we can't use api version greater than 1.7 as our minimal supported Gradle version 7.6 uses kotlin-stdlib 1.7
557
-
apiVersion.set(KotlinVersion.KOTLIN_1_7)
558
-
}
559
-
freeCompilerArgs.addAll(
560
-
listOf(
561
-
"-Xskip-prerelease-check",
562
-
"-Xsuppress-version-warnings",
563
-
// We have to override the default value for `-Xsam-conversions` to `class`
564
-
// otherwise the compiler would compile lambdas using invokedynamic,
565
-
// such lambdas are not serializable so are not compatible with Gradle configuration cache.
566
-
// It doesn't lead to a significant difference in binaries sizes, and previously (before LV 1.5) the `class` value was set by default.
567
-
"-Xsam-conversions=class",
568
-
)
569
-
)
561
+
/**
562
+
* Configures the JVM compile task to produce binaries compatible with [GradlePluginVariant.GRADLE_MIN].
563
+
*/
564
+
fun KotlinCompile.configureGradleCompatibility() {
565
+
configureRunViaKotlinBuildToolsApi()
566
+
compilerOptions {
567
+
if (!project.kotlinBuildProperties.isInJpsBuildIdeaSync) {
568
+
val variant =GradlePluginVariant.GRADLE_MIN
569
+
// we should keep control of the language version for compatibility with bundled Kotlin compiler for Gradle Kotlin scripts.
* Configures the task to execute the Kotlin compiler via the Kotlin Build Tools API.
601
+
*
602
+
* This way, we use an older bootstrap compiler controlled by the `kotlin-for-gradle-plugins-compilation`
603
+
* version catalog entry to ensure compatibility with older language versions
604
+
*
605
+
* It's using reflection to access internal property instead of the `kotlin.compiler.runViaBuildToolsApi` property to avoid using it for test source sets.
606
+
* This way, we can the latest AV/LV in test code as well as dependencies built with them.
Copy file name to clipboardExpand all lines: repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/gradle-plugin-common-configuration.gradle.kts
+1-1
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ val signPublication = !version.toString().contains("-SNAPSHOT") &&
Copy file name to clipboardExpand all lines: repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/gradle-plugin-dependency-configuration.gradle.kts
Copy file name to clipboardExpand all lines: repo/gradle-build-conventions/gradle-plugins-common/src/main/kotlin/gradle/GradlePluginVariant.kt
+14-11
Original file line number
Diff line number
Diff line change
@@ -7,24 +7,27 @@ package gradle
7
7
8
8
/**
9
9
* Gradle's plugins common variants.
10
+
* See also the compatibility matrix: https://docs.gradle.org/current/userguide/compatibility.html#kotlin
10
11
*
11
-
* [minimalSupportedGradleVersion] - minimal Gradle version that is supported in this variant
12
+
* [minimalSupportedGradleVersion] - Minimal Gradle version that is supported in this variant
12
13
* [gradleApiVersion] - Gradle API dependency version. Usually should be the same as [minimalSupportedGradleVersion].
13
-
* [gradleApiJavadocUrl] - Gradle URL for the given API. Last enum entry should always point to 'current'.
14
+
* [gradleApiJavadocUrl] - Gradle URL for the given API.The last enum entry should always point to 'current'.
15
+
* [bundledKotlinVersion] - The version of the bundled Kotlin. Used to control the kotlin-stdlib version and the values of `-api-version`, `-language-version` arguments
0 commit comments