Skip to content

Commit 7a34598

Browse files
committed
chore: kotlin 2.1.20-RC update and misc changes
1 parent 8950a6a commit 7a34598

File tree

8 files changed

+133
-63
lines changed

8 files changed

+133
-63
lines changed

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ enableMavenSnapshot=false
6565
# Other projects
6666
composeBuild=true
6767
springBoot=false
68-
nativeBuild=false
69-
nativeWinTarget=false
68+
kotlin.target.native.enabled=false
69+
kotlin.target.win.enabled=false
7070
debug=false

gradle/build-logic/src/main/kotlin/common/Multiplatform.kt

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import org.gradle.kotlin.dsl.*
77
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
88
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
99
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
10+
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBinaryMode
1011
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
1112

1213
fun KotlinMultiplatformExtension.commonTarget(project: Project) =
@@ -101,7 +102,7 @@ fun KotlinMultiplatformExtension.jvmTarget(project: Project) =
101102
// val test by testRuns.existing
102103
testRuns.configureEach { executionTask.configure { configureJavaTest() } }
103104

104-
// Configure application executable only it's enabled
105+
// Configures JavaExec task with name "runJvm" and Gradle distribution "jvmDistZip"
105106
if (isKmpExecEnabled) {
106107
binaries {
107108
executable {
@@ -112,14 +113,6 @@ fun KotlinMultiplatformExtension.jvmTarget(project: Project) =
112113
}
113114
}
114115

115-
// Register a task to execute a class using jvm runtime dependencies.
116-
// compilations.getByName("test") {
117-
// tasks.register<JavaExec>("ktExec") {
118-
// classpath(runtimeDependencyFiles, output)
119-
// mainClass = "dev.suresh.test.ExecMain"
120-
// }
121-
// }
122-
123116
// attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.jvm)
124117
}
125118

@@ -255,6 +248,37 @@ fun KotlinMultiplatformExtension.wasmJsTarget(project: Project) =
255248
}
256249
}
257250

251+
fun KotlinMultiplatformExtension.wasmWasiTarget(project: Project) =
252+
with(project) {
253+
wasmWasi {
254+
nodejs()
255+
if (isSharedProject.not()) {
256+
binaries
257+
.executable()
258+
.filter { it.mode == KotlinJsBinaryMode.PRODUCTION }
259+
.forEach { binary ->
260+
val wasmFilename = binary.mainFileName.map { it.replaceAfterLast(".", "wasm") }
261+
val wasmFile =
262+
binary.linkTask.flatMap { it.destinationDirectory.file(wasmFilename) }
263+
// Add generated WASM binary as maven publication
264+
mavenPublication { artifact(wasmFile) { classifier = targetName } }
265+
}
266+
}
267+
268+
compilations.all {
269+
compileTaskProvider.configure {
270+
compilerOptions.freeCompilerArgs.addAll(
271+
listOf("-Xwasm-use-traps-instead-of-exceptions"))
272+
}
273+
}
274+
}
275+
276+
sourceSets {
277+
wasmWasiMain { dependencies {} }
278+
wasmWasiTest { kotlin {} }
279+
}
280+
}
281+
258282
fun KotlinMultiplatformExtension.hostNativeTarget(configure: KotlinNativeTarget.() -> Unit = {}) =
259283
when {
260284
Platform.isMac -> {
@@ -275,10 +299,7 @@ fun KotlinMultiplatformExtension.nativeTargets(
275299
configure: KotlinNativeTarget.() -> Unit = {}
276300
) =
277301
with(project) {
278-
val nativeBuild: String? by project
279-
val nativeWinTarget: String? by project
280-
281-
if (nativeBuild.toBoolean()) {
302+
if (isNativeTargetEnabled) {
282303
fun KotlinNativeTarget.configureAll() {
283304
compilerOptions {
284305
// freeCompilerArgs.addAll("-Xverbose-phases=Linker", "-Xruntime-logs=gc=info")
@@ -297,11 +318,18 @@ fun KotlinMultiplatformExtension.nativeTargets(
297318
macosArm64 { configureAll() }
298319
linuxX64 { configureAll() }
299320
linuxArm64 { configureAll() }
300-
if (nativeWinTarget.toBoolean()) {
321+
if (isWinTargetEnabled) {
301322
mingwX64 { configureAll() }
302323
}
303324

304-
sourceSets { nativeMain { dependencies { api(libs.ktor.client.curl) } } }
325+
sourceSets {
326+
nativeMain {
327+
dependencies {
328+
// On native targets, only curl currently supports TLS
329+
api(libs.ktor.client.curl)
330+
}
331+
}
332+
}
305333
}
306334
}
307335

gradle/build-logic/src/main/kotlin/common/ProjectExtns.kt

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import org.gradle.api.artifacts.VersionCatalogsExtension
1818
import org.gradle.api.attributes.*
1919
import org.gradle.api.component.AdhocComponentWithVariants
2020
import org.gradle.api.plugins.JavaPluginExtension
21+
import org.gradle.api.provider.*
2122
import org.gradle.api.tasks.*
2223
import org.gradle.api.tasks.compile.JavaCompile
2324
import org.gradle.api.tasks.testing.*
@@ -59,25 +60,31 @@ val Project.buildLogicProjectName
5960
val Project.isSharedProject
6061
get() = name == sharedProjectName
6162

62-
// val debug: String? by project
63-
val Project.debugEnabled
64-
get() = providers.gradleProperty("debug").map(String::toBoolean).getOrElse(false)
65-
6663
val Project.skipTest
67-
get() = providers.gradleProperty("skip.test").map(String::toBoolean).getOrElse(false)
64+
get() = gradleBooleanProperty("skip.test").get()
6865

6966
val Project.hasCleanTask
7067
get() = gradle.startParameter.taskNames.any { it in listOf("clean", "cleanAll") }
7168

72-
val Project.isSnapshotVersion
73-
get() = version.toString().endsWith("SNAPSHOT", true)
74-
7569
val Project.runsOnCI
7670
get() = providers.environmentVariable("CI").isPresent
7771

72+
// val debug: String? by project
73+
val Project.debugEnabled
74+
get() = gradleBooleanProperty("debug").get()
75+
76+
val Project.isSnapshotVersion
77+
get() = version.toString().endsWith("SNAPSHOT", true)
78+
7879
val Project.isKmpExecEnabled
7980
get() = extra.has("enableKmpExec") && extra["enableKmpExec"] as Boolean
8081

82+
val Project.isNativeTargetEnabled: Boolean
83+
get() = gradleBooleanProperty("kotlin.target.native.enabled").get()
84+
85+
val Project.isWinTargetEnabled: Boolean
86+
get() = gradleBooleanProperty("kotlin.target.win.enabled").get()
87+
8188
/** Java version properties. */
8289
val Project.javaVersion
8390
get() = libs.versions.java.asProvider().map { JavaVersion.toVersion(it) }
@@ -110,6 +117,9 @@ val Project.kotlinLangVersion
110117
val Project.orgName
111118
get() = libs.versions.org.name.get()
112119

120+
val Project.orgUrl
121+
get() = libs.versions.org.url.get()
122+
113123
val Project.githubUser
114124
get() = libs.versions.dev.name.get().lowercase()
115125

@@ -705,6 +715,9 @@ fun Project.addFileToJavaComponent(file: File) {
705715
}
706716
}
707717

718+
fun Project.gradleBooleanProperty(name: String): Provider<Boolean> =
719+
providers.gradleProperty(name).map(String::toBoolean).orElse(false)
720+
708721
/** Lazy version of [TaskContainer.maybeCreate] */
709722
inline fun <reified T : Task> TaskContainer.maybeRegister(
710723
name: String,

gradle/build-logic/src/main/kotlin/dev.suresh.plugin.kotlin.mpp.gradle.kts

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@file:Suppress("UnstableApiUsage")
22
@file:OptIn(ExperimentalKotlinGradlePluginApi::class, ExperimentalBCVApi::class)
33

4+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
45
import com.google.devtools.ksp.gradle.KspAATask
56
import com.javiersc.kotlin.kopy.args.KopyFunctions
67
import common.*
@@ -34,6 +35,8 @@ plugins {
3435
// dev.mokkery
3536
}
3637

38+
configurations.configureEach { resolutionStrategy { failOnNonReproducibleResolution() } }
39+
3740
kotlin {
3841
commonTarget(project)
3942
when (project.name) {
@@ -147,6 +150,34 @@ tasks {
147150
}
148151
}
149152

153+
pluginManager.withPlugin("com.gradleup.shadow") {
154+
// Register a shadowJar task for the default jvm target
155+
val mainCompilation = kotlin.jvm().compilations.getByName("main")
156+
val shadowJvmJar by
157+
registering(ShadowJar::class) {
158+
from(tasks.named("jvmJar"))
159+
// from(mainCompilation.output.allOutputs) -> allOutputs == classes + resources
160+
val runtimeDepConfig =
161+
project.configurations.getByName(mainCompilation.runtimeDependencyConfigurationName)
162+
configurations = listOf(runtimeDepConfig)
163+
archiveClassifier = "all"
164+
mergeServiceFiles()
165+
manifest {
166+
attributes[Attributes.Name.MAIN_CLASS.toString()] = libs.versions.app.mainclass
167+
}
168+
}
169+
170+
val buildExecutable by
171+
registering(ReallyExecJar::class) {
172+
jarFile = shadowJvmJar.flatMap { it.archiveFile }
173+
javaOpts = jvmRunArgs
174+
execJarFile = layout.buildDirectory.dir("libs").map { it.file("${project.name}-app") }
175+
onlyIf { OperatingSystem.current().isUnix }
176+
}
177+
178+
build { finalizedBy(buildExecutable) }
179+
}
180+
150181
pluginManager.withPlugin("org.jetbrains.kotlinx.binary-compatibility-validator") {
151182
configure<ApiValidationExtension> {
152183
ignoredPackages.add("dev.suresh.test")
@@ -156,22 +187,9 @@ tasks {
156187
}
157188

158189
withType<KotlinApiBuildTask>().configureEach {
159-
// inputJar = named<Jar>("shadowJar").flatMap { it.archiveFile }
190+
// inputJar = named<Jar>("shadowJvmJar").flatMap { it.archiveFile }
160191
}
161192
}
162-
163-
pluginManager.withPlugin("com.gradleup.shadow") {
164-
val buildExecutable by
165-
registering(ReallyExecJar::class) {
166-
jarFile = named<Jar>("shadowJar").flatMap { it.archiveFile }
167-
// javaOpts = application.applicationDefaultJvmArgs
168-
javaOpts = named<JavaExec>("run").get().jvmArgs
169-
execJarFile = layout.buildDirectory.dir("libs").map { it.file("${project.name}-app") }
170-
onlyIf { OperatingSystem.current().isUnix }
171-
}
172-
173-
build { finalizedBy(buildExecutable) }
174-
}
175193
}
176194

177195
var npmEnabled: String? by rootProject.extra

gradle/kotlin-js-store/package-lock.json

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradle/libs.versions.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ kotlin-jvmtarget = "21"
66
kotlin-dsl-jvmtarget = "21"
77
kotlin-api-version = "2.1"
88
kotlin-lang-version = "2.1"
9-
gradle = "8.13-rc-1"
9+
gradle = "8.13-rc-2"
1010
java-vendor = "Oracle"
1111
java-jvmArguments = "--enable-preview"
1212
java-addModules = "jdk.incubator.vector"
@@ -20,7 +20,7 @@ org-name = "suresh.dev"
2020
org-url = "https://suresh.dev"
2121

2222
# Gradle Dependencies Versions
23-
bc-plugins = "1.12.0"
23+
bc-plugins = "1.13.0"
2424
kotlinx-kover = "0.9.1"
2525
kotlinx-bcv = "0.17.0"
2626
kotlin-dokka = "2.0.0"
@@ -83,7 +83,7 @@ jsch = "0.2.23"
8383
pty4j = "0.13.2"
8484
junit = "5.12.0-RC2"
8585
koin = "4.1.0-Beta5"
86-
koin-annotations = "2.0.0-RC1"
86+
koin-annotations = "2.0.0-RC4"
8787
kotest = "6.0.0.M2"
8888
mockk = "1.13.16"
8989
mokkery = "2.7.0"
@@ -149,7 +149,7 @@ apache-commons-imaging = "1.0-alpha5"
149149
testcontainers = "1.20.5"
150150
sourceBuddy = "2.5.0"
151151
tcp-javanioproxy = "1.6"
152-
kubernetes-client = "22.0.1"
152+
kubernetes-client = "23.0.0"
153153
reflect-typeparamresolver = "1.0.2"
154154
reflect-typetools = "0.6.3"
155155
async-profiler = "3.0"

0 commit comments

Comments
 (0)