Skip to content

Commit 538a959

Browse files
committed
Build all possible targets
Previously only a single native target was built and it depended on the user's host machine OS (0.1 in Maven Central only supprots `linux64`). This enables all targets supported per https://kotlinlang.org/docs/multiplatform-dsl-reference.html#targets. Unfortunately this requires deploying from two OSes: Mac OS and Linux. - If you deploy from Mac OS every target is built except for `linuxMips32` and `linuxMipsel32`. These can be published to Sonatype as part of a separate call to ./gradlew \ publishLinuxMips32PublicationToSonatypeRepository \ publishLinuxMipsel32PublicationToSonatypeRepository` and then both repositories closed & released at once. - If you deploy from Linux none of the Mac OS targets are built. They can be published to Sonatype as part of a separate call to ./gradlew \ publishIosArm32PublicationToSonatypeRepository \ publishIosArm64PublicationToSonatypeRepository \ publishIosSimulatorArm64PublicationToSonatypeRepository \ publishIosX64PublicationToSonatypeRepository \ publishMacosArm64PublicationToSonatypeRepository \ publishMacosX64PublicationToSonatypeRepository \ publishTvosArm64PublicationToSonatypeRepository \ publishTvosSimulatorArm64PublicationToSonatypeRepository \ publishTvosX64PublicationToSonatypeRepository \ publishWatchosArm32PublicationToSonatypeRepository \ publishWatchosArm64PublicationToSonatypeRepository \ publishWatchosDeviceArm64PublicationToSonatypeRepository \ publishWatchosSimulatorArm64PublicationToSonatypeRepository \ publishWatchosX64PublicationToSonatypeRepository \ publishWatchosX86PublicationToSonatypeRepository and then both repositories closed & released at once.
1 parent 9c38fc9 commit 538a959

File tree

5 files changed

+46
-93
lines changed

5 files changed

+46
-93
lines changed

build.gradle.kts

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import java.util.Properties
22
import org.gradle.api.publish.maven.MavenPublication
33
import org.gradle.api.tasks.bundling.Jar
4+
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
45

56
plugins {
67
kotlin("multiplatform") version "1.8.0"
@@ -16,53 +17,73 @@ repositories {
1617
}
1718

1819
kotlin {
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

File renamed without changes.
File renamed without changes.

src/nativeMain/kotlin/CodePoints.kt

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/nativeMain/kotlin/StringExtensions.kt

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)