From a60217b0256c2b1f21b3fe05e4441ffda0e84efd Mon Sep 17 00:00:00 2001 From: Romain BOISSELLE Date: Sat, 14 Dec 2024 15:37:04 +0100 Subject: [PATCH] Update to Kotlin 2.1.0 and migrate to KotlinBaseExtension --- build.gradle.kts | 7 ++----- gradle/globals.versions.toml | 2 +- gradle/libs.versions.toml | 2 +- kodein-internal-gradle-settings/build.gradle.kts | 4 +--- .../kotlin/org/kodein/internal/gradle/KodeinJvmPlugin.kt | 4 ++-- .../org/kodein/internal/gradle/KodeinMppExtension.kt | 8 ++++---- 6 files changed, 11 insertions(+), 16 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 26454e0..8481f7a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,5 @@ import okhttp3.OkHttpClient import okhttp3.Request -import org.jetbrains.kotlin.builtins.StandardNames.FqNames.target @Suppress("DSL_SCOPE_VIOLATION") plugins { @@ -22,7 +21,7 @@ buildscript { allprojects { group = "org.kodein.internal.gradle" - version = "8.9.0" + version = "8.10.0" } repositories { @@ -50,9 +49,7 @@ dependencies { kotlin { explicitApi() - target.compilations.all { - kotlinOptions.jvmTarget = "17" - } + jvmToolchain(17) sourceSets.all { languageSettings.progressiveMode = true diff --git a/gradle/globals.versions.toml b/gradle/globals.versions.toml index 5d2fab3..717f0cc 100644 --- a/gradle/globals.versions.toml +++ b/gradle/globals.versions.toml @@ -1,5 +1,5 @@ [versions] -kotlin = "2.0.21" +kotlin = "2.1.0" dokka = "1.9.20" android-gradle-plugin = "8.5.2" android-ndk = "25.2.9519653" diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c48584b..7996cd3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,7 @@ git-publish = "4.2.2" gradle-develocityPlugin = "3.19" gradle-publishPlugin = "1.3.0" # https://docs.gradle.org/current/userguide/compatibility.html#kotlin -kotlin = "1.9.22" +kotlin = "2.0.20" okhttp = "4.12.0" [plugins] diff --git a/kodein-internal-gradle-settings/build.gradle.kts b/kodein-internal-gradle-settings/build.gradle.kts index 9c30def..1e746fd 100644 --- a/kodein-internal-gradle-settings/build.gradle.kts +++ b/kodein-internal-gradle-settings/build.gradle.kts @@ -18,9 +18,7 @@ dependencies { kotlin { explicitApi() - target.compilations.all { - kotlinOptions.jvmTarget = "17" - } + jvmToolchain(17) } buildConfig { diff --git a/src/main/kotlin/org/kodein/internal/gradle/KodeinJvmPlugin.kt b/src/main/kotlin/org/kodein/internal/gradle/KodeinJvmPlugin.kt index 517c180..512c351 100644 --- a/src/main/kotlin/org/kodein/internal/gradle/KodeinJvmPlugin.kt +++ b/src/main/kotlin/org/kodein/internal/gradle/KodeinJvmPlugin.kt @@ -7,15 +7,15 @@ import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.getByName import org.gradle.kotlin.dsl.getByType import org.gradle.kotlin.dsl.withType +import org.jetbrains.kotlin.gradle.dsl.KotlinBaseExtension import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension -import org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile public class KodeinJvmPlugin : KtPlugin { internal companion object { - fun configureJvmTarget(project: Project, kotlin: KotlinTopLevelExtension) = with(project) { + fun configureJvmTarget(project: Project, kotlin: KotlinBaseExtension) = with(project) { kotlin.jvmToolchain(jvmTarget(project)) tasks.withType().configureEach { if (KodeinLocalPropertiesPlugin.on(project).isNotTrue("allowWarnings")) { diff --git a/src/main/kotlin/org/kodein/internal/gradle/KodeinMppExtension.kt b/src/main/kotlin/org/kodein/internal/gradle/KodeinMppExtension.kt index a2b924a..407a1f9 100644 --- a/src/main/kotlin/org/kodein/internal/gradle/KodeinMppExtension.kt +++ b/src/main/kotlin/org/kodein/internal/gradle/KodeinMppExtension.kt @@ -5,8 +5,8 @@ import org.gradle.api.NamedDomainObjectProvider import org.gradle.api.Project import org.gradle.internal.os.OperatingSystem import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl +import org.jetbrains.kotlin.gradle.dsl.KotlinBaseExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension -import org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet @@ -125,7 +125,7 @@ public open class KodeinMppExtension( ): Target = Target(name, kotlinAccess, ::Sources, nativeBuildOn, defaultConfig) public fun > TargetBuilder<*, C, out Sources>.commonJvmConfig( - kotlin: KotlinTopLevelExtension, + kotlin: KotlinBaseExtension, ) { kotlin.jvmToolchain(KodeinJvmPlugin.jvmTarget(project)) @@ -161,13 +161,13 @@ public open class KodeinMppExtension( // TODO: Try again with Kotlin 2.0.0 // Because Chrome 11* on CI is not compatible // https://youtrack.jetbrains.com/issue/KT-63014 - testTask { enabled = false } + testTask { enabled = true } } if (jsEnvNodejs) target.nodejs { // TODO: Try again with Kotlin 2.0.0 // Because Chrome 11* on CI is not compatible // https://youtrack.jetbrains.com/issue/KT-63014 - testTask { enabled = false } + testTask { enabled = true } } if (jsEnvD8) target.d8() }