Skip to content

Commit

Permalink
Update Kotlin to 2.0.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Oct 18, 2024
1 parent c28fcf3 commit 7e4d21a
Show file tree
Hide file tree
Showing 14 changed files with 171 additions and 567 deletions.
4 changes: 2 additions & 2 deletions gradle/build-logic/build-logic.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2023 Björn Kautler
* Copyright 2020-2024 Björn Kautler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,7 +29,7 @@ dependencies {
implementation(plugin(libs.plugins.release))
implementation(plugin(libs.plugins.grgit))
implementation(plugin(libs.plugins.github))
implementation(plugin(libs.plugins.kotlin.js))
implementation(plugin(libs.plugins.kotlin.multiplatform))
implementation(":dependency-updates-report-aggregation")
implementation(libs.build.inject)
implementation(libs.build.github.api)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2023 Björn Kautler
* Copyright 2020-2024 Björn Kautler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,6 +30,7 @@ import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtLiteralStringTemplateEntry
import org.jetbrains.kotlin.psi.KtStringTemplateExpression
import java.nio.file.Path

plugins {
`java-base`
Expand Down Expand Up @@ -110,20 +111,25 @@ val File.importedFiles: List<File>
.project
)
.findFile(
CoreLocalVirtualFile(
CoreLocalFileSystem(),
this
)
// work-around for API change between version we compile against and version we run against
// after upgrading Gradle to a version that contains Kotlin 1.9 the embeddable compiler can
// be upgraded to v2 also for compilation and then this can be removed
CoreLocalVirtualFile::class
.java
.getConstructor(CoreLocalFileSystem::class.java, Path::class.java)
.newInstance(CoreLocalFileSystem(), toPath())
)
.let { it as KtFile }
.fileAnnotationList
?.annotationEntries
?.asSequence()
?.filter { it.shortName?.asString() == "Import" }
?.flatMap { it.valueArgumentList?.arguments ?: emptyList() }
?.mapNotNull { it.getArgumentExpression() as? KtStringTemplateExpression }
?.map { it.entries.first() }
?.mapNotNull { it as? KtLiteralStringTemplateEntry }
?.map { resolveSibling(it.text) }
?.flatMap { it.importedFiles + it }
?.toList()
?: emptyList()
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2023 Björn Kautler
* Copyright 2020-2024 Björn Kautler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,25 +19,38 @@ package net.kautler
import net.kautler.util.npm
import org.gradle.accessors.dm.LibrariesForLibs
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsExec
import org.jetbrains.kotlin.gradle.tasks.IncrementalSyncTask

plugins {
kotlin("js")
kotlin("multiplatform")
}

val libs = the<LibrariesForLibs>()

kotlin {
js(IR) {
js {
useCommonJs()
binaries.executable()
nodejs()
}

sourceSets {
jsMain {
dependencies {
implementation(libs.kotlinx.coroutines.core)
implementation(dependencies.platform(libs.kotlin.wrappers.bom))
implementation(libs.kotlin.wrapper.js)
implementation(libs.kotlin.wrapper.node)
implementation(npm(libs.build.vercel.ncc))
}
}
}
}

// work-around for https://youtrack.jetbrains.com/issue/KT-56305
tasks.withType<Copy>().configureEach {
if (name.endsWith("ExecutableCompileSync")) {
doFirst {
outputs.files.forEach { it.deleteRecursively() }
}
tasks.withType<IncrementalSyncTask>().configureEach {
doFirst {
outputs.files.forEach { it.deleteRecursively() }
}
}

Expand All @@ -55,7 +68,7 @@ tasks.withType<NodeJsExec>().configureEach {
input.fileProvider(
rootProject
.tasks
.named<Copy>("productionExecutableCompileSync")
.named<IncrementalSyncTask>("jsProductionExecutableCompileSync")
.map {
it
.outputs
Expand All @@ -77,13 +90,3 @@ tasks.withType<NodeJsExec>().configureEach {
}
argumentProviders.add(objects.newInstance<ArgumentProvider>(rootProject))
}

val libs = the<LibrariesForLibs>()

dependencies {
implementation(libs.kotlinx.coroutines.core)
implementation(platform(libs.kotlin.wrappers.bom))
implementation(libs.kotlin.wrapper.js)
implementation(libs.kotlin.wrapper.node)
implementation(npm(libs.build.vercel.ncc))
}
49 changes: 24 additions & 25 deletions gradle/build-logic/src/main/kotlin/net/kautler/node.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,41 @@ import net.kautler.util.npm
import org.gradle.accessors.dm.LibrariesForLibs
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsExec
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.kotlin.gradle.tasks.IncrementalSyncTask
import org.yaml.snakeyaml.Yaml

plugins {
kotlin("js")
kotlin("multiplatform")
}

val libs = the<LibrariesForLibs>()

kotlin {
js(IR) {
js {
useCommonJs()
binaries.executable()
nodejs()
}

sourceSets {
jsMain {
dependencies {
implementation(libs.kotlinx.coroutines.core)
implementation(dependencies.platform(libs.kotlin.wrappers.bom))
implementation(libs.kotlin.wrapper.actions.toolkit)
implementation(libs.kotlin.wrapper.js)
implementation(libs.kotlin.wrapper.node)
implementation(npm(libs.semver))
implementation(npm(libs.nullWritable))
}
}
}
}

// work-around for https://youtrack.jetbrains.com/issue/KT-56305
tasks.withType<Copy>().configureEach {
if (name.endsWith("ExecutableCompileSync")) {
doFirst {
outputs.files.forEach { it.deleteRecursively() }
}
tasks.withType<IncrementalSyncTask>().configureEach {
doFirst {
outputs.files.forEach { it.deleteRecursively() }
}
}

Expand Down Expand Up @@ -76,26 +91,10 @@ tasks.withType<NodeJsExec>().configureEach {
}
}

val libs = the<LibrariesForLibs>()

configure<NodeJsRootExtension> {
nodeVersion = libs.versions.build.node.get()
}

dependencies {
implementation(libs.kotlinx.coroutines.core)
implementation(platform(libs.kotlin.wrappers.bom))
implementation(libs.kotlin.wrapper.actions.toolkit)
implementation(libs.kotlin.wrapper.js)
implementation(libs.kotlin.wrapper.node)
implementation(npm(libs.semver))
implementation(npm(libs.nullWritable))
version = libs.versions.build.node.get()
}

tasks.assemble {
dependsOn(project(":ncc-packer").tasks.named("nodeProductionRun"))
}

fun plugin(plugin: Provider<PluginDependency>) = plugin.map {
"${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version.requiredVersion}"
dependsOn(project(":ncc-packer").tasks.named("jsNodeProductionRun"))
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2023 Björn Kautler
* Copyright 2020-2024 Björn Kautler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,17 +16,16 @@

package net.kautler.util

import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.MinimalExternalModuleDependency
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.provider.Provider
import org.jetbrains.kotlin.gradle.targets.js.npm.NpmDependency
import org.jetbrains.kotlin.gradle.targets.js.npm.NpmDependencyExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler

fun DependencyHandler.npm(
fun KotlinDependencyHandler.npm(
dependency: Provider<MinimalExternalModuleDependency>
): NpmDependency {
): Dependency {
val dep = dependency.get()
return (extensions.getByName("npm") as NpmDependencyExtension)(
return npm(
name = if (dep.group == "<unscoped>") dep.name else "@${dep.group}/${dep.name}",
version = dep.version!!
)
Expand Down
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020-2023 Björn Kautler
# Copyright 2020-2024 Björn Kautler
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -25,12 +25,12 @@ build-kotlinx-serialization = "1.5.0"
build-node = "20.11.0"
build-snakeyaml = "2.0"
build-vercel-ncc = "0.36.1"
kotlin = "1.8.20"
kotlin = "2.0.20"
kotlin-wrappers = "1.0.0-pre.529"
kotlinx-coroutines = "1.6.4"
nullWritable = "1.0.5"
semver = "7.3.8"
workflows-kotlin = "1.8.20"
workflows-kotlin = "2.0.20"

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

0 comments on commit 7e4d21a

Please sign in to comment.