Update Kotlin to 2.0 (#900)

- update Kotlin from 1.7.10 to 2.0.21
  - Kotlin 1.6 dependencies in Gradle lock files are expected because kotlinc,
    which is also used by some tests, internally uses some 1.6 dependencies
    for backwards compatibility reasons.
- update kotlinx-html and kotlinx-serialization
- adapt Kotlin code where necessary
- use Kotlin stdlib Path APIs where possible
- fix IntelliJ Kotlin inspection warnings
- reformat code with `./gradlew spotlessApply`
  - ktfmt adds lots of trailing commas
- Add workaround to fix IntelliJ "unresolved reference" errors
This commit is contained in:
odenix
2025-01-23 14:41:59 -08:00
committed by GitHub
parent cdd6d52642
commit 258eda8630
87 changed files with 1042 additions and 1004 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins { `kotlin-dsl` }
dependencies {
@@ -31,4 +33,4 @@ java {
targetCompatibility = JavaVersion.VERSION_17
}
kotlin { target { compilations.configureEach { kotlinOptions { jvmTarget = "17" } } } }
kotlin { compilerOptions { jvmTarget = JvmTarget.JVM_17 } }

View File

@@ -15,6 +15,7 @@
*/
import com.diffplug.gradle.spotless.KotlinGradleExtension
import org.gradle.accessors.dm.LibrariesForLibs
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins { id("com.diffplug.spotless") }
@@ -48,9 +49,9 @@ plugins.withType(JavaPlugin::class).configureEach {
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs = freeCompilerArgs + listOf("-Xjsr305=strict", "-Xjvm-default=all")
compilerOptions {
jvmTarget = JvmTarget.JVM_17
freeCompilerArgs.addAll("-Xjsr305=strict", "-Xjvm-default=all")
}
}