Update the kotlin compiler and add an OptIn annotation to Configuration.kt

This commit is contained in:
Username404 2021-07-26 11:38:40 +02:00
parent 7de5800d11
commit 596eb27fff
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
2 changed files with 11 additions and 3 deletions

View File

@ -10,8 +10,8 @@ buildscript {
} }
plugins { plugins {
kotlin("jvm") version "1.5.21" kotlin("jvm") version "1.5.30-M1"
kotlin("plugin.serialization") version "1.5.21" kotlin("plugin.serialization") version "1.5.30-M1"
id("com.github.johnrengelman.shadow") version "7.0.0" apply false id("com.github.johnrengelman.shadow") version "7.0.0" apply false
id("architectury-plugin") version "[3.0.100, 3.3[" id("architectury-plugin") version "[3.0.100, 3.3["
id("dev.architectury.loom") version ( id("dev.architectury.loom") version (
@ -41,6 +41,10 @@ val serializationVer: String by rootProject
val mcBase: String = rootProject.architectury.minecraft.substring(0..3) val mcBase: String = rootProject.architectury.minecraft.substring(0..3)
val kotlinX: String = "org.jetbrains.kotlinx" val kotlinX: String = "org.jetbrains.kotlinx"
val toolchainJavaVersion = Action<JavaToolchainSpec> {
languageVersion.set(JavaLanguageVersion.of(sourceJavaVer.toInt()))
}
subprojects { subprojects {
group = rootProject.group.toString() group = rootProject.group.toString()
apply(plugin = "org.cqfn.diktat.diktat-gradle-plugin") apply(plugin = "org.cqfn.diktat.diktat-gradle-plugin")
@ -172,7 +176,8 @@ allprojects {
apply(plugin = "java") apply(plugin = "java")
apply(plugin = "org.jetbrains.kotlin.jvm") apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "architectury-plugin") 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 { dependencies {
implementation(kotlin("stdlib-jdk8", kotlinVer)) implementation(kotlin("stdlib-jdk8", kotlinVer))
implementation(kotlin("reflect", kotlinVer)) implementation(kotlin("reflect", kotlinVer))
@ -180,6 +185,7 @@ allprojects {
} }
tasks { tasks {
withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) { withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) {
kotlinJavaToolchain.toolchain.use(launcher)
with(kotlinOptions) { with(kotlinOptions) {
// https://github.com/JetBrains/kotlin/blob/master/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt // https://github.com/JetBrains/kotlin/blob/master/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt
freeCompilerArgs = listOf( freeCompilerArgs = listOf(

View File

@ -24,11 +24,13 @@ import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.decodeFromString import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import kotlin.reflect.full.isSuperclassOf import kotlin.reflect.full.isSuperclassOf
@OptIn(ExperimentalSerializationApi::class)
object Configuration { object Configuration {
@Deprecated("Use the getValue or setValue methods instead", level = DeprecationLevel.ERROR) @Deprecated("Use the getValue or setValue methods instead", level = DeprecationLevel.ERROR)
@JvmStatic @JvmStatic