From 18c3d03576ae68fa93926ee7ab4c50a6b8975626 Mon Sep 17 00:00:00 2001 From: Yang Date: Fri, 10 Nov 2023 01:39:09 +1100 Subject: [PATCH] Kotlin 1.9.20. Disable k2 due to failing tests. Java 21 toolchain. --- build.gradle.kts | 44 +++++++++++++++++++++------------------ gradle.properties | 1 - gradle/libs.versions.toml | 4 +--- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f7b96de..0256ae5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,8 +1,7 @@ import com.google.cloud.tools.jib.gradle.BuildImageTask import com.netflix.graphql.dgs.codegen.gradle.GenerateJavaTask import io.gitlab.arturbosch.detekt.Detekt -import org.jetbrains.kotlin.gradle.dsl.KotlinVersion -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { alias(libs.plugins.kotlin.jvm) @@ -58,9 +57,30 @@ dependencies { kotlin { jvmToolchain { - languageVersion.set(JavaLanguageVersion.of(20)) + languageVersion.set(JavaLanguageVersion.of(21)) vendor.set(JvmVendorSpec.AZUL) } + compilerOptions { + // languageVersion.set(KotlinVersion.KOTLIN_2_0) TODO enable once tests pass with K2 + freeCompilerArgs.addAll( + "-opt-in=kotlin.RequiresOptIn", + "-Xjsr305=strict", + "-Xcontext-receivers", + ) + } +} + +tasks.withType().configureEach { + useJUnitPlatform() + maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) +} + +configurations.configureEach { + resolutionStrategy.eachDependency { + if (this@configureEach.name == "detekt" && requested.group == "org.jetbrains.kotlin") { + useVersion("1.9.10") + } + } } allprojects { @@ -72,29 +92,13 @@ allprojects { } tasks.withType().configureEach { reports { + jvmTarget = JvmTarget.JVM_20.target // TODO remove once detekt supports JVM 21 bytecode html.outputLocation.set(file("build/reports/detekt/${project.name}.html")) } } dependencies.add("detektPlugins", libs.detektFormatting) } -tasks.withType().configureEach { - compilerOptions { - languageVersion.set(KotlinVersion.KOTLIN_2_0) - freeCompilerArgs.addAll( - "-opt-in=kotlin.RequiresOptIn", - "-Xjsr305=strict", - "-Xcontext-receivers", - "-Xbackend-threads=0", - ) - } -} - -tasks.withType().configureEach { - useJUnitPlatform() - maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) -} - fun Project.envOrProp(name: String): String { return providers.environmentVariable(name).orNull ?: providers.gradleProperty(name).orNull diff --git a/gradle.properties b/gradle.properties index 6aa3e6d..ecbf122 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,4 +7,3 @@ org.gradle.configuration-cache-problems=warn # Kotlin code style kotlin.code.style=official -kotlin.experimental.tryK2=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 63edb6f..c3948c2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,13 +1,11 @@ [versions] -kotlin = "1.9.10" +kotlin = "1.9.20" spring-boot = "3.1.5" spring-dependencyManagement = "1.1.3" jib = "3.4.0" ktor = "2.3.6" dgsBom = "8.0.1" dgsCodegen = "6.0.3" -kotlinx-coroutines = "1.7.2" -kotlinx-serialization = "1.5.1" detekt = "1.23.3" apacheCommonsText = "1.10.0" caffeine = "3.1.8"