diff --git a/build.gradle.kts b/build.gradle.kts index 6665215a..7bc7c884 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,6 +5,7 @@ import org.jetbrains.gradle.ext.copyright import org.jetbrains.gradle.ext.settings import org.jetbrains.kotlin.gradle.dsl.KotlinVersion import kotlin.math.min +import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile plugins { id("org.jetbrains.kotlin.jvm") version "1.8.22" @@ -145,7 +146,6 @@ val e2eTest: SourceSet by sourceSets.creating { runtimeClasspath += sourceSets["main"].output } -@Suppress("UnstableApiUsage") // `configurations` container is incubating configurations { compatTestCompileClasspath { extendsFrom(testCompileClasspath.get()) @@ -170,44 +170,28 @@ sourceSets { } } -kotlin.target.compilations.configureEach { - // Supporting Gradle 6.2+ needs to use Kotlin 1.3. - // See https://docs.gradle.org/current/userguide/compatibility.html - // For future maintainer: Kotlin 1.9.0 dropped support for Kotlin 1.3, it'll only support 1.4+. - // This means Gradle 7.0 will be the lowest supportable version for plugins. - val usedKotlinVersion = @Suppress("DEPRECATION") KotlinVersion.KOTLIN_1_3 +tasks { + withType().configureEach { + compilerOptions { + // Gradle fully supports running on Java 8: https://docs.gradle.org/current/userguide/compatibility.html, + // so we should allow users to do that too. + jvmTarget = JvmTarget.JVM_1_8 - compilerOptions.configure { - // Gradle fully supports running on Java 8: https://docs.gradle.org/current/userguide/compatibility.html, - // so we should allow users to do that too. - jvmTarget = JvmTarget.fromTarget(JavaVersion.VERSION_1_8.toString()) + // Suppress "Language version 1.3 is deprecated and its support will be removed in a future version of Kotlin". + freeCompilerArgs.add("-Xsuppress-version-warnings") - // Suppress "Language version 1.3 is deprecated and its support will be removed in a future version of Kotlin". - freeCompilerArgs.add("-Xsuppress-version-warnings") - } - compileTaskProvider.configure { - // These two (api & lang) needs to be here instead of in compilations.compilerOptions.configure { }, - // to prevent KotlinDslCompilerPlugins overriding to Kotlin 1.8. - compilerOptions.apiVersion = usedKotlinVersion - // Theoretically we could use newer language version here, - // but sadly the @kotlin.Metadata created on the classes would be incompatible with older consumers. - compilerOptions.languageVersion = usedKotlinVersion + // Supporting Gradle 6.2+ needs to use Kotlin 1.3. + // See https://docs.gradle.org/current/userguide/compatibility.html + // For future maintainer: Kotlin 1.9.0 dropped support for Kotlin 1.3, it'll only support 1.4+. + // This means Gradle 7.0 will be the lowest supportable version for plugins. + val usedKotlinVersion = @Suppress("DEPRECATION") KotlinVersion.KOTLIN_1_3 - // Validate that we're using the right version. - doFirst { - val api = compilerOptions.apiVersion.get() - val language = compilerOptions.languageVersion.get() - if (api != usedKotlinVersion || language != usedKotlinVersion) { - TODO( - "There's mismatch between configured and actual versions:\n" + - "apiVersion=${api}, languageVersion=${language}, configured=${usedKotlinVersion}." - ) - } + apiVersion = usedKotlinVersion + // Theoretically we could use newer language version here, + // but sadly the @kotlin.Metadata created on the classes would be incompatible with older consumers. + languageVersion = usedKotlinVersion } } -} - -tasks { shadowJar { exclude("META-INF/maven/**", "META-INF/proguard/**", "META-INF/*.kotlin_module") manifest {