From 1532f155c0dca6354f5f93dad37b7acb7af1e465 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 20 May 2024 13:25:06 +0100 Subject: [PATCH 1/2] Avoid `-Xexpect-actual-classes` flag before Kotlin 1.9.20 --- .../io/spine/internal/gradle/kotlin/KotlinConfig.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/io/spine/internal/gradle/kotlin/KotlinConfig.kt b/buildSrc/src/main/kotlin/io/spine/internal/gradle/kotlin/KotlinConfig.kt index 7a94730a..c4e3dbf7 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/gradle/kotlin/KotlinConfig.kt +++ b/buildSrc/src/main/kotlin/io/spine/internal/gradle/kotlin/KotlinConfig.kt @@ -53,18 +53,22 @@ fun KotlinJvmProjectExtension.applyJvmToolchain(version: String) = */ @Suppress("unused") fun KotlinCompile.setFreeCompilerArgs() { + // Avoid the "unsupported flag warning" for Kotlin compilers pre 1.9.20. + // See: https://youtrack.jetbrains.com/issue/KT-61573 + val expectActualClasses = + if (KotlinVersion.CURRENT.isAtLeast(1, 9, 20)) "-Xexpect-actual-classes" else "" kotlinOptions { freeCompilerArgs = listOf( "-Xskip-prerelease-check", "-Xjvm-default=all", "-Xinline-classes", - "-Xexpect-actual-classes", + expectActualClasses, "-opt-in=" + "kotlin.contracts.ExperimentalContracts," + "kotlin.io.path.ExperimentalPathApi," + "kotlin.ExperimentalUnsignedTypes," + "kotlin.ExperimentalStdlibApi," + "kotlin.experimental.ExperimentalTypeInference", - ) + ).filter { it.isNotBlank() } } } From 589a95cf3c876b0f8ddc2195481f9742c5eae4a7 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 20 May 2024 13:30:12 +0100 Subject: [PATCH 2/2] Avoid `-Xexpect-actual-classes` flag before Kotlin 1.9.20 --- .../main/kotlin/io/spine/internal/gradle/kotlin/KotlinConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/io/spine/internal/gradle/kotlin/KotlinConfig.kt b/buildSrc/src/main/kotlin/io/spine/internal/gradle/kotlin/KotlinConfig.kt index c4e3dbf7..955a5464 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/gradle/kotlin/KotlinConfig.kt +++ b/buildSrc/src/main/kotlin/io/spine/internal/gradle/kotlin/KotlinConfig.kt @@ -51,7 +51,7 @@ fun KotlinJvmProjectExtension.applyJvmToolchain(version: String) = /** * Opts-in to experimental features that we use in our codebase. */ -@Suppress("unused") +@Suppress("unused", "MagicNumber" /* Kotlin Compiler version. */) fun KotlinCompile.setFreeCompilerArgs() { // Avoid the "unsupported flag warning" for Kotlin compilers pre 1.9.20. // See: https://youtrack.jetbrains.com/issue/KT-61573