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..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,20 +51,24 @@ 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 + 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() } } }