1+ @file:OptIn(ExperimentalWasmDsl ::class )
2+
3+ import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
14import org.jetbrains.kotlin.gradle.dsl.JvmTarget
25import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
6+ import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
7+ import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions
38
49plugins {
510 alias(libs.plugins.kotlin.multiplatform)
611 alias(libs.plugins.kotlin.serialization)
712 alias(libs.plugins.maven.publish)
813}
914
10- tasks.withType< org.jetbrains.kotlin.gradle.tasks.KotlinCompile > {
11- compilerOptions {
15+ val versionConfigure: KotlinCommonCompilerOptions .() -> Unit = {
16+ languageVersion = KotlinVersion .KOTLIN_2_0
17+ apiVersion = KotlinVersion .KOTLIN_2_0
18+ if (this is KotlinJvmCompilerOptions ) {
1219 jvmTarget = JvmTarget .JVM_11
13- languageVersion = KotlinVersion .KOTLIN_2_0
14- apiVersion = KotlinVersion .KOTLIN_2_0
1520 }
1621}
1722
18- kotlin {
19- jvm {
20- compilerOptions {
21- jvmTarget = JvmTarget .JVM_11
22- languageVersion = KotlinVersion .KOTLIN_2_0
23- apiVersion = KotlinVersion .KOTLIN_2_0
24- }
25- }
23+ tasks.withType< org.jetbrains.kotlin.gradle.tasks.KotlinCompile > {
24+ compilerOptions(versionConfigure)
25+ }
2626
27- // Kotlin/Native - Linux
28- linuxX64()
29- linuxArm64()
27+ kotlin {
28+ explicitApi()
29+ applyDefaultHierarchyTemplate()
30+ compilerOptions(versionConfigure)
3031
31- // Kotlin/Native - Windows
32- mingwX64 ()
32+ androidNativeArm64()
33+ androidNativeX64 ()
3334
34- // Kotlin/Native - Apple
3535 iosArm64()
3636 iosSimulatorArm64()
3737 iosX64()
38+
39+ js().nodejs()
40+
41+ jvm { compilerOptions(versionConfigure) }
42+
43+ linuxArm64()
44+ linuxX64()
45+
3846 macosArm64()
3947 macosX64()
48+
49+ mingwX64()
50+
4051 tvosArm64()
4152 tvosSimulatorArm64()
4253 tvosX64()
54+
55+ wasmJs().nodejs()
56+ wasmWasi().nodejs()
57+
4358 watchosArm64()
59+ watchosDeviceArm64()
60+ watchosSimulatorArm64()
4461 watchosX64()
4562
4663 sourceSets {
4764 commonMain {
48- compilerOptions {
49- languageVersion = KotlinVersion .KOTLIN_2_0
50- apiVersion = KotlinVersion .KOTLIN_2_0
51- }
65+ compilerOptions(versionConfigure)
5266 dependencies {
5367 api(libs.kotlinx.serialization.json)
5468 }
@@ -62,10 +76,11 @@ kotlin {
6276 }
6377}
6478
65- // tip: it will take about 1 hour after GitHub Actions finished
6679mavenPublishing {
67- publishToMavenCentral()
68- signAllPublications()
80+ if (properties.contains(" signing.keyId" )) {
81+ publishToMavenCentral()
82+ signAllPublications()
83+ }
6984 coordinates(" li.songe" , " json5" , " 0.4.1" )
7085
7186 val repoUrl = " https://github.com/lisonge/kotlin-json5"
0 commit comments