Skip to content

Commit 7e4d21a

Browse files
committed
Update Kotlin to 2.0.20
1 parent c28fcf3 commit 7e4d21a

File tree

14 files changed

+171
-567
lines changed

14 files changed

+171
-567
lines changed

gradle/build-logic/build-logic.gradle.kts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2023 Björn Kautler
2+
* Copyright 2020-2024 Björn Kautler
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@ dependencies {
2929
implementation(plugin(libs.plugins.release))
3030
implementation(plugin(libs.plugins.grgit))
3131
implementation(plugin(libs.plugins.github))
32-
implementation(plugin(libs.plugins.kotlin.js))
32+
implementation(plugin(libs.plugins.kotlin.multiplatform))
3333
implementation(":dependency-updates-report-aggregation")
3434
implementation(libs.build.inject)
3535
implementation(libs.build.github.api)

gradle/build-logic/src/main/kotlin/net/kautler/github_actions.gradle.kts

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2023 Björn Kautler
2+
* Copyright 2020-2024 Björn Kautler
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.config.CompilerConfiguration
3030
import org.jetbrains.kotlin.psi.KtFile
3131
import org.jetbrains.kotlin.psi.KtLiteralStringTemplateEntry
3232
import org.jetbrains.kotlin.psi.KtStringTemplateExpression
33+
import java.nio.file.Path
3334

3435
plugins {
3536
`java-base`
@@ -110,20 +111,25 @@ val File.importedFiles: List<File>
110111
.project
111112
)
112113
.findFile(
113-
CoreLocalVirtualFile(
114-
CoreLocalFileSystem(),
115-
this
116-
)
114+
// work-around for API change between version we compile against and version we run against
115+
// after upgrading Gradle to a version that contains Kotlin 1.9 the embeddable compiler can
116+
// be upgraded to v2 also for compilation and then this can be removed
117+
CoreLocalVirtualFile::class
118+
.java
119+
.getConstructor(CoreLocalFileSystem::class.java, Path::class.java)
120+
.newInstance(CoreLocalFileSystem(), toPath())
117121
)
118122
.let { it as KtFile }
119123
.fileAnnotationList
120124
?.annotationEntries
125+
?.asSequence()
121126
?.filter { it.shortName?.asString() == "Import" }
122127
?.flatMap { it.valueArgumentList?.arguments ?: emptyList() }
123128
?.mapNotNull { it.getArgumentExpression() as? KtStringTemplateExpression }
124129
?.map { it.entries.first() }
125130
?.mapNotNull { it as? KtLiteralStringTemplateEntry }
126131
?.map { resolveSibling(it.text) }
127132
?.flatMap { it.importedFiles + it }
133+
?.toList()
128134
?: emptyList()
129135
}

gradle/build-logic/src/main/kotlin/net/kautler/ncc_packer.gradle.kts

+22-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2023 Björn Kautler
2+
* Copyright 2020-2024 Björn Kautler
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,25 +19,38 @@ package net.kautler
1919
import net.kautler.util.npm
2020
import org.gradle.accessors.dm.LibrariesForLibs
2121
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsExec
22+
import org.jetbrains.kotlin.gradle.tasks.IncrementalSyncTask
2223

2324
plugins {
24-
kotlin("js")
25+
kotlin("multiplatform")
2526
}
2627

28+
val libs = the<LibrariesForLibs>()
29+
2730
kotlin {
28-
js(IR) {
31+
js {
2932
useCommonJs()
3033
binaries.executable()
3134
nodejs()
3235
}
36+
37+
sourceSets {
38+
jsMain {
39+
dependencies {
40+
implementation(libs.kotlinx.coroutines.core)
41+
implementation(dependencies.platform(libs.kotlin.wrappers.bom))
42+
implementation(libs.kotlin.wrapper.js)
43+
implementation(libs.kotlin.wrapper.node)
44+
implementation(npm(libs.build.vercel.ncc))
45+
}
46+
}
47+
}
3348
}
3449

3550
// work-around for https://youtrack.jetbrains.com/issue/KT-56305
36-
tasks.withType<Copy>().configureEach {
37-
if (name.endsWith("ExecutableCompileSync")) {
38-
doFirst {
39-
outputs.files.forEach { it.deleteRecursively() }
40-
}
51+
tasks.withType<IncrementalSyncTask>().configureEach {
52+
doFirst {
53+
outputs.files.forEach { it.deleteRecursively() }
4154
}
4255
}
4356

@@ -55,7 +68,7 @@ tasks.withType<NodeJsExec>().configureEach {
5568
input.fileProvider(
5669
rootProject
5770
.tasks
58-
.named<Copy>("productionExecutableCompileSync")
71+
.named<IncrementalSyncTask>("jsProductionExecutableCompileSync")
5972
.map {
6073
it
6174
.outputs
@@ -77,13 +90,3 @@ tasks.withType<NodeJsExec>().configureEach {
7790
}
7891
argumentProviders.add(objects.newInstance<ArgumentProvider>(rootProject))
7992
}
80-
81-
val libs = the<LibrariesForLibs>()
82-
83-
dependencies {
84-
implementation(libs.kotlinx.coroutines.core)
85-
implementation(platform(libs.kotlin.wrappers.bom))
86-
implementation(libs.kotlin.wrapper.js)
87-
implementation(libs.kotlin.wrapper.node)
88-
implementation(npm(libs.build.vercel.ncc))
89-
}

gradle/build-logic/src/main/kotlin/net/kautler/node.gradle.kts

+24-25
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,41 @@ import net.kautler.util.npm
2121
import org.gradle.accessors.dm.LibrariesForLibs
2222
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsExec
2323
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
24+
import org.jetbrains.kotlin.gradle.tasks.IncrementalSyncTask
2425
import org.yaml.snakeyaml.Yaml
2526

2627
plugins {
27-
kotlin("js")
28+
kotlin("multiplatform")
2829
}
2930

31+
val libs = the<LibrariesForLibs>()
32+
3033
kotlin {
31-
js(IR) {
34+
js {
3235
useCommonJs()
3336
binaries.executable()
3437
nodejs()
3538
}
39+
40+
sourceSets {
41+
jsMain {
42+
dependencies {
43+
implementation(libs.kotlinx.coroutines.core)
44+
implementation(dependencies.platform(libs.kotlin.wrappers.bom))
45+
implementation(libs.kotlin.wrapper.actions.toolkit)
46+
implementation(libs.kotlin.wrapper.js)
47+
implementation(libs.kotlin.wrapper.node)
48+
implementation(npm(libs.semver))
49+
implementation(npm(libs.nullWritable))
50+
}
51+
}
52+
}
3653
}
3754

3855
// work-around for https://youtrack.jetbrains.com/issue/KT-56305
39-
tasks.withType<Copy>().configureEach {
40-
if (name.endsWith("ExecutableCompileSync")) {
41-
doFirst {
42-
outputs.files.forEach { it.deleteRecursively() }
43-
}
56+
tasks.withType<IncrementalSyncTask>().configureEach {
57+
doFirst {
58+
outputs.files.forEach { it.deleteRecursively() }
4459
}
4560
}
4661

@@ -76,26 +91,10 @@ tasks.withType<NodeJsExec>().configureEach {
7691
}
7792
}
7893

79-
val libs = the<LibrariesForLibs>()
80-
8194
configure<NodeJsRootExtension> {
82-
nodeVersion = libs.versions.build.node.get()
83-
}
84-
85-
dependencies {
86-
implementation(libs.kotlinx.coroutines.core)
87-
implementation(platform(libs.kotlin.wrappers.bom))
88-
implementation(libs.kotlin.wrapper.actions.toolkit)
89-
implementation(libs.kotlin.wrapper.js)
90-
implementation(libs.kotlin.wrapper.node)
91-
implementation(npm(libs.semver))
92-
implementation(npm(libs.nullWritable))
95+
version = libs.versions.build.node.get()
9396
}
9497

9598
tasks.assemble {
96-
dependsOn(project(":ncc-packer").tasks.named("nodeProductionRun"))
97-
}
98-
99-
fun plugin(plugin: Provider<PluginDependency>) = plugin.map {
100-
"${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version.requiredVersion}"
99+
dependsOn(project(":ncc-packer").tasks.named("jsNodeProductionRun"))
101100
}

gradle/build-logic/src/main/kotlin/net/kautler/util/DependencyHandlerExtension.kt renamed to gradle/build-logic/src/main/kotlin/net/kautler/util/KotlinDependencyHandlerExtension.kt

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2023 Björn Kautler
2+
* Copyright 2020-2024 Björn Kautler
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,17 +16,16 @@
1616

1717
package net.kautler.util
1818

19+
import org.gradle.api.artifacts.Dependency
1920
import org.gradle.api.artifacts.MinimalExternalModuleDependency
20-
import org.gradle.api.artifacts.dsl.DependencyHandler
2121
import org.gradle.api.provider.Provider
22-
import org.jetbrains.kotlin.gradle.targets.js.npm.NpmDependency
23-
import org.jetbrains.kotlin.gradle.targets.js.npm.NpmDependencyExtension
22+
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
2423

25-
fun DependencyHandler.npm(
24+
fun KotlinDependencyHandler.npm(
2625
dependency: Provider<MinimalExternalModuleDependency>
27-
): NpmDependency {
26+
): Dependency {
2827
val dep = dependency.get()
29-
return (extensions.getByName("npm") as NpmDependencyExtension)(
28+
return npm(
3029
name = if (dep.group == "<unscoped>") dep.name else "@${dep.group}/${dep.name}",
3130
version = dep.version!!
3231
)

gradle/libs.versions.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020-2023 Björn Kautler
1+
# Copyright 2020-2024 Björn Kautler
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -25,12 +25,12 @@ build-kotlinx-serialization = "1.5.0"
2525
build-node = "20.11.0"
2626
build-snakeyaml = "2.0"
2727
build-vercel-ncc = "0.36.1"
28-
kotlin = "1.8.20"
28+
kotlin = "2.0.20"
2929
kotlin-wrappers = "1.0.0-pre.529"
3030
kotlinx-coroutines = "1.6.4"
3131
nullWritable = "1.0.5"
3232
semver = "7.3.8"
33-
workflows-kotlin = "1.8.20"
33+
workflows-kotlin = "2.0.20"
3434

3535
[libraries]
3636
build-github-api = { module = "org.kohsuke:github-api", version.ref = "build-github-api" }
@@ -62,7 +62,7 @@ convention-readme = { id = "net.kautler.readme", version = "?" }
6262
dependency-analysis = { id = "com.autonomousapps.dependency-analysis", version.ref = "build-gradle-plugin-dependency-analysis" }
6363
github = { id = "net.wooga.github", version.ref = "build-gradle-plugin-github" }
6464
grgit = { id = "org.ajoberstar.grgit.service", version.ref = "build-gradle-plugin-grgit" }
65-
kotlin-js = { id = "org.jetbrains.kotlin.js", version.ref = "kotlin" }
65+
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
6666
refresh-versions = { id = "de.fayard.refreshVersions", version.ref = "build-gradle-plugin-refresh-versions" }
6767
release = { id = "net.researchgate.release", version.ref = "build-gradle-plugin-release" }
6868
versions = { id = "com.github.ben-manes.versions", version.ref = "build-gradle-plugin-versions" }

0 commit comments

Comments
 (0)