11import java.util.Properties
22import org.gradle.api.publish.maven.MavenPublication
33import org.gradle.api.tasks.bundling.Jar
4+ import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
45
56plugins {
67 kotlin(" multiplatform" ) version " 1.8.0"
@@ -16,53 +17,73 @@ repositories {
1617}
1718
1819kotlin {
20+ androidNativeArm32()
21+ androidNativeArm64()
22+ androidNativeX86()
23+ androidNativeX64()
24+
25+ iosArm32()
26+ iosArm64()
27+ iosX64()
28+ iosSimulatorArm64()
29+
30+ js(IR ) {
31+ browser {}
32+ }
33+
1934 jvm {
2035 compilations.all {
2136 kotlinOptions.jvmTarget = " 11"
2237 }
23- withJava()
2438 testRuns[" test" ].executionTask.configure {
2539 useJUnitPlatform()
2640 }
2741 }
28-
29- js(IR ) {
30- browser {}
31- }
32-
33- val hostOs = System .getProperty(" os.name" )
34- val isMingwX64 = hostOs.startsWith(" Windows" )
35- val nativeTarget = when {
36- hostOs == " Mac OS X" -> macosX64(" native" )
37- hostOs == " Linux" -> linuxX64(" native" )
38- isMingwX64 -> mingwX64(" native" )
39- else -> throw GradleException (" Host OS is not supported in Kotlin/Native." )
40- }
41-
42- sourceSets {
43- val commonImplementation by creating
4442
43+ linuxArm64()
44+ linuxArm32Hfp()
45+ linuxX64()
46+
47+ macosX64()
48+ macosArm64()
49+
50+ mingwX64()
51+ mingwX86()
52+
53+ tvosArm64()
54+ tvosX64()
55+ tvosSimulatorArm64()
56+
57+ wasm32()
58+
59+ watchosArm32()
60+ watchosArm64()
61+ watchosDeviceArm64()
62+ watchosX86()
63+ watchosX64()
64+ watchosSimulatorArm64()
65+
66+ sourceSets {
4567 val commonMain by getting
4668 val commonTest by getting {
4769 dependencies {
4870 implementation(kotlin(" test" ))
4971 }
5072 }
5173
52- val jvmMain by getting
53- val jvmTest by getting {
54- dependsOn(commonImplementation)
74+ val commonImplementation by creating {
75+ dependsOn(commonMain)
5576 }
5677
57- val jsMain by getting {
78+ val jvmTest by getting {
5879 dependsOn(commonImplementation)
5980 }
60- val jsTest by getting
81+ }
6182
62- val nativeMain by getting {
63- dependsOn(commonImplementation)
83+ targets.onEach {
84+ if (it.platformType != KotlinPlatformType .jvm) {
85+ it.compilations.getByName(" main" ).source(sourceSets.getByName(" commonImplementation" ))
6486 }
65- val nativeTest by getting
6687 }
6788}
6889
0 commit comments