1- import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
2- import org.jetbrains.kotlin.konan.target.Family.ANDROID
3- import org.jetbrains.kotlin.konan.target.Family.LINUX
4- import org.jetbrains.kotlin.konan.target.Family.MINGW
5-
6- buildscript {
7- dependencies {
8- classpath(" com.vanniktech:gradle-maven-publish-plugin:0.25.3" )
9- }
10- }
1+ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
2+ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
3+ import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
114
125plugins {
13- kotlin(" multiplatform" )
14- }
15-
16- repositories {
17- mavenCentral()
18- google()
6+ alias(libs.plugins.kotlin.multiplatform)
7+ alias(libs.plugins.mavenPublish)
198}
209
2110val GROUP : String by project
@@ -25,7 +14,10 @@ group = GROUP
2514version = VERSION_NAME
2615
2716kotlin {
28- targetHierarchy.default()
17+ @OptIn(ExperimentalKotlinGradlePluginApi ::class )
18+ compilerOptions {
19+ freeCompilerArgs.add(" -Xexpect-actual-classes" )
20+ }
2921 macosX64()
3022 iosX64()
3123 iosArm64()
@@ -55,73 +47,29 @@ kotlin {
5547 browser()
5648 nodejs()
5749 }
58- wasm {
50+ @OptIn(ExperimentalWasmDsl ::class )
51+ wasmJs {
5952 browser()
60- binaries.executable ()
53+ nodejs ()
6154 }
6255
63- sourceSets {
64- val commonMain by getting
65- val commonTest by getting {
66- dependencies {
67- implementation(kotlin(" test" ))
56+ @Suppress(" OPT_IN_USAGE" )
57+ applyDefaultHierarchyTemplate {
58+ common {
59+ group(" jsAndWasmJs" ) {
60+ withJs()
61+ withWasm()
6862 }
6963 }
64+ }
7065
71- val jsWasmMain by creating {
72- dependsOn(commonMain)
73- }
74- val jsWasmTest by creating {
75- dependsOn(commonTest)
76- }
77- val jsMain by getting {
78- dependsOn(jsWasmMain)
79- }
80- val jsTest by getting {
81- dependsOn(jsWasmTest)
82- }
83- val wasmMain by getting {
84- dependsOn(jsWasmMain)
85- }
86- val wasmTest by getting {
87- dependsOn(jsWasmTest)
88- }
89-
90- val nativeCommonMain by creating {
91- dependsOn(commonMain)
92- }
93- val nativeCommonTest by creating {
94- dependsOn(commonTest)
95- }
96-
97- val nativeDarwinMain by creating {
98- dependsOn(nativeCommonMain)
99- }
100- val nativeLinuxMain by creating {
101- dependsOn(nativeCommonMain)
102- }
103- val mingwMain by getting {
104- dependsOn(nativeCommonMain)
105- }
106-
107- targets.withType<KotlinNativeTarget >().all {
108- val mainSourceSet = compilations.getByName(" main" ).defaultSourceSet
109- val testSourceSet = compilations.getByName(" test" ).defaultSourceSet
110-
111- mainSourceSet.dependsOn(nativeCommonMain)
112- testSourceSet.dependsOn(nativeCommonTest)
113-
114- when {
115- konanTarget.family == MINGW -> mainSourceSet.dependsOn(mingwMain)
116- konanTarget.family == LINUX || konanTarget.family == ANDROID -> mainSourceSet.dependsOn(
117- nativeLinuxMain
118- )
119-
120- konanTarget.family.isAppleFamily -> mainSourceSet.dependsOn(nativeDarwinMain)
121- else -> mainSourceSet.dependsOn(nativeCommonMain)
122- }
123- }
66+ sourceSets.commonTest.dependencies {
67+ implementation(kotlin(" test" ))
12468 }
12569}
12670
127- apply (plugin = " com.vanniktech.maven.publish" )
71+ // https://github.com/Kotlin/kotlin-wasm-examples/commit/701a051d6ee869abcabebff702b3ccd98d51c38d
72+ rootProject.the<NodeJsRootExtension >().apply {
73+ nodeVersion = " 21.0.0-v8-canary202309143a48826a08"
74+ nodeDownloadBaseUrl = " https://nodejs.org/download/v8-canary"
75+ }
0 commit comments