From 596eb27fff82e51d04bf337d5ab86f9fa9c3ea9c Mon Sep 17 00:00:00 2001 From: Username404 Date: Mon, 26 Jul 2021 11:38:40 +0200 Subject: [PATCH] Update the kotlin compiler and add an OptIn annotation to Configuration.kt --- build.gradle.kts | 12 +++++++++--- .../fr/username404/snowygui/config/Configuration.kt | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7f04752..3ecd361 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,8 +10,8 @@ buildscript { } plugins { - kotlin("jvm") version "1.5.21" - kotlin("plugin.serialization") version "1.5.21" + kotlin("jvm") version "1.5.30-M1" + kotlin("plugin.serialization") version "1.5.30-M1" id("com.github.johnrengelman.shadow") version "7.0.0" apply false id("architectury-plugin") version "[3.0.100, 3.3[" id("dev.architectury.loom") version ( @@ -41,6 +41,10 @@ val serializationVer: String by rootProject val mcBase: String = rootProject.architectury.minecraft.substring(0..3) val kotlinX: String = "org.jetbrains.kotlinx" +val toolchainJavaVersion = Action { + languageVersion.set(JavaLanguageVersion.of(sourceJavaVer.toInt())) +} + subprojects { group = rootProject.group.toString() apply(plugin = "org.cqfn.diktat.diktat-gradle-plugin") @@ -172,7 +176,8 @@ allprojects { apply(plugin = "java") apply(plugin = "org.jetbrains.kotlin.jvm") apply(plugin = "architectury-plugin") - val compiler = javaToolchains.compilerFor { languageVersion.set(JavaLanguageVersion.of(sourceJavaVer.toInt())) } + val compiler = javaToolchains.compilerFor(toolchainJavaVersion) + val launcher = javaToolchains.launcherFor(toolchainJavaVersion) dependencies { implementation(kotlin("stdlib-jdk8", kotlinVer)) implementation(kotlin("reflect", kotlinVer)) @@ -180,6 +185,7 @@ allprojects { } tasks { withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) { + kotlinJavaToolchain.toolchain.use(launcher) with(kotlinOptions) { // https://github.com/JetBrains/kotlin/blob/master/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt freeCompilerArgs = listOf( diff --git a/common/src/main/kotlin/fr/username404/snowygui/config/Configuration.kt b/common/src/main/kotlin/fr/username404/snowygui/config/Configuration.kt index 49b9286..f53d75d 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/config/Configuration.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/config/Configuration.kt @@ -24,11 +24,13 @@ import kotlinx.coroutines.CoroutineStart import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking +import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import kotlin.reflect.full.isSuperclassOf +@OptIn(ExperimentalSerializationApi::class) object Configuration { @Deprecated("Use the getValue or setValue methods instead", level = DeprecationLevel.ERROR) @JvmStatic