Skip to content

Commit

Permalink
Add wasmJs target (#3805)
Browse files Browse the repository at this point in the history
Includes:
* Migrating to Kotlin 1.9.23 (with support for 2.0.0-Beta2), Gradle 8.6
* Using kotlinx.coroutines 1.8.0
* Simplifying the source set hierarchy in build scripts
* Adding a common `jsHosted` source set for JS-hosted targets (`js` and
`wasmJs`)
* Removing `watchosX86` and `iosArm32` targets
* Deprecating `kotest-extensions-http`, meanwhile restricting it to JVM

Fixes #3598.

---------

Co-authored-by: Emil Kantis <emil.kantis@protonmail.com>
Co-authored-by: Sam <sam@sksamuel.com>
  • Loading branch information
3 people committed Mar 12, 2024
1 parent 23b0629 commit 2a61950
Show file tree
Hide file tree
Showing 115 changed files with 648 additions and 409 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
target:
- jvmTest
- jsTest
- wasmJsTest
- linuxX64Test linuxArm64TestKlibrary
- androidNativeX86TestKlibrary androidNativeX64TestKlibrary androidNativeArm32TestKlibrary androidNativeArm64TestKlibrary
- :kotest-framework:kotest-framework-multiplatform-plugin-gradle:test
Expand All @@ -77,9 +78,9 @@ jobs:
matrix:
target:
- macosX64Test macosArm64Test
- iosX64Test iosSimulatorArm64Test iosArm64TestKlibrary iosArm32TestKlibrary
- iosX64Test iosSimulatorArm64Test iosArm64TestKlibrary
- tvosX64Test tvosArm64TestKlibrary tvosSimulatorArm64Test
- watchosArm32TestKlibrary watchosArm64TestKlibrary watchosX86Test watchosX64Test watchosSimulatorArm64Test watchosDeviceArm64TestKlibrary
- watchosArm32TestKlibrary watchosArm64TestKlibrary watchosX64Test watchosSimulatorArm64Test watchosDeviceArm64TestKlibrary
uses: ./.github/workflows/run-gradle.yml
with:
runs-on: macos-latest
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
target:
- jvmTest publishJvmPublicationToDeployRepository publishKotlinMultiplatformPublicationToDeployRepository publishKotestBomPublicationToDeployRepository
- jsTest publishJsPublicationToDeployRepository
- wasmJsTest publishWasmJsPublicationToDeployRepository
- linuxX64Test publishLinuxX64PublicationToDeployRepository
- linuxArm64TestKlibrary publishLinuxArm64PublicationToDeployRepository
- androidNativeX86TestKlibrary androidNativeX64TestKlibrary publishAndroidNativeX64PublicationToDeployRepository publishAndroidNativeX86PublicationToDeployRepository
Expand All @@ -69,12 +70,10 @@ jobs:
- iosX64Test publishIosX64PublicationToDeployRepository
- iosSimulatorArm64Test publishIosSimulatorArm64PublicationToDeployRepository
- iosArm64TestKlibrary publishIosArm64PublicationToDeployRepository
- iosArm32TestKlibrary publishIosArm32PublicationToDeployRepository
- tvosX64Test publishTvosX64PublicationToDeployRepository
- tvosArm64TestKlibrary publishTvosArm64PublicationToDeployRepository
- watchosArm32TestKlibrary publishWatchosArm32PublicationToDeployRepository
- watchosArm64TestKlibrary publishWatchosArm64PublicationToDeployRepository
- watchosX86Test publishWatchosX86PublicationToDeployRepository
- watchosX64Test publishWatchosX64PublicationToDeployRepository
- watchosSimulatorArm64Test publishWatchosSimulatorArm64PublicationToDeployRepository
- tvosSimulatorArm64Test publishTvosSimulatorArm64PublicationToDeployRepository
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
- "publishIosX64PublicationToDeployRepository"
- "publishIosSimulatorArm64PublicationToDeployRepository"
- "publishIosArm64PublicationToDeployRepository"
- "publishIosArm32PublicationToDeployRepository"
steps:
- name: Checkout the repo
uses: actions/checkout@v4
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release_watchos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
target:
- "publishWatchosArm32PublicationToDeployRepository"
- "publishWatchosArm64PublicationToDeployRepository"
- "publishWatchosX86PublicationToDeployRepository"
- "publishWatchosX64PublicationToDeployRepository"
- "publishWatchosSimulatorArm64PublicationToDeployRepository"
steps:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@file:Suppress("UNUSED_VARIABLE")
import org.jetbrains.kotlin.gradle.plugin.KotlinHierarchyTemplate


plugins {
id("kotlin-conventions")
Expand All @@ -10,22 +11,15 @@ kotlin {
androidNativeX64()
androidNativeArm32()
androidNativeArm64()
sourceSets {

// Main source sets
val commonMain by getting {}
val desktopMain by getting { dependsOn(commonMain) }
val androidNativeX86Main by getting { dependsOn(desktopMain) }
val androidNativeX64Main by getting { dependsOn(desktopMain) }
val androidNativeArm32Main by getting { dependsOn(desktopMain) }
val androidNativeArm64Main by getting { dependsOn(desktopMain) }

val commonTest by getting
val nativeTest by getting { dependsOn(commonTest) }
val androidNativeX86Test by getting { dependsOn(nativeTest) }
val androidNativeX64Test by getting { dependsOn(nativeTest) }
val androidNativeArm32Test by getting { dependsOn(nativeTest) }
val androidNativeArm64Test by getting { dependsOn(nativeTest) }
// TODO: The "desktop" intermediate source set can be integrated into "native". In this case
// the following block can be replaced with `applyDefaultHierarchyTemplate()`.
applyHierarchyTemplate(KotlinHierarchyTemplate.default) {
group("common") {
group("desktop") {
withNative()
}
}
}
} else {
// Make sure every project has at least one valid target, otherwise Kotlin compiler will complain
Expand Down
44 changes: 43 additions & 1 deletion buildSrc/src/main/kotlin/kotest-js-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,57 @@
import org.jetbrains.kotlin.gradle.plugin.KotlinHierarchyTemplate

plugins {
id("kotlin-conventions")
}

kotlin {
if (!project.hasProperty(Ci.JVM_ONLY)) {
js(IR) {
js {
browser()
nodejs()
}

wasmJs {
browser()
nodejs()
}

/* FIXME: enable wasmWasi when there is support in kotlinx-coroutines-core (1.8.0-RC does only wasmJs)
wasmWasi {
nodejs()
}
*/

applyHierarchyTemplate(KotlinHierarchyTemplate.default) {
group("common") {
group("jsHosted") {
withJs()
withWasm() // FIXME: KT-63417 – to be split into `withWasmJs` and `withWasmWasi`
}
}
}
} else {
// Make sure every project has at least one valid target, otherwise Kotlin compiler will complain
jvm()
}
}

// FIXME: WORKAROUND https://youtrack.jetbrains.com/issue/KT-65864
// Use a Node.js version current enough to support Kotlin/Wasm

rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> {
rootProject.extensions.configure<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension> {
// Initialize once in a multi-project build.
// Otherwise, Gradle would complain "Configuration already finalized for previous property values".
if (!System.getProperty("nodeJsCanaryConfigured").toBoolean()) {
nodeVersion = "22.0.0-nightly2024010568c8472ed9"
println("Using Node.js $nodeVersion to support Kotlin/Wasm")
nodeDownloadBaseUrl = "https://nodejs.org/download/nightly"
System.setProperty("nodeJsCanaryConfigured", "true")
}
}
}

rootProject.tasks.withType<org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask>().configureEach {
args.add("--ignore-engines") // Prevent Yarn from complaining about newer Node.js versions.
}
2 changes: 0 additions & 2 deletions buildSrc/src/main/kotlin/kotest-jvm-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("UNUSED_VARIABLE")

plugins {
id("kotlin-conventions")
}
Expand Down
70 changes: 9 additions & 61 deletions buildSrc/src/main/kotlin/kotest-native-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@file:Suppress("UNUSED_VARIABLE")
import org.jetbrains.kotlin.gradle.plugin.KotlinHierarchyTemplate


plugins {
id("kotlin-conventions")
Expand All @@ -20,74 +21,21 @@ kotlin {

watchosArm32()
watchosArm64()
watchosX86()
watchosX64()
watchosSimulatorArm64()

iosX64()
iosArm64()
iosArm32()
iosSimulatorArm64()

sourceSets {

// Main source sets
val commonMain by getting {}

val desktopMain by creating {
dependsOn(commonMain)
// FIXME: The "desktop" intermediate source set can be integrated into "native". In this case
// the following block can be replaced with `applyDefaultHierarchyTemplate()`.
applyHierarchyTemplate(KotlinHierarchyTemplate.default) {
group("common") {
group("desktop") {
withNative()
}
}

val macosX64Main by getting { dependsOn(desktopMain) }
val macosArm64Main by getting { dependsOn(desktopMain) }

val mingwX64Main by getting { dependsOn(desktopMain) }

val linuxX64Main by getting { dependsOn(desktopMain) }
val linuxArm64Main by getting { dependsOn(desktopMain) }

val iosX64Main by getting { dependsOn(desktopMain) }
val iosArm64Main by getting { dependsOn(desktopMain) }
val iosArm32Main by getting { dependsOn(desktopMain) }
val iosSimulatorArm64Main by getting { dependsOn(desktopMain) }

val watchosArm32Main by getting { dependsOn(desktopMain) }
val watchosArm64Main by getting { dependsOn(desktopMain) }
val watchosX86Main by getting { dependsOn(desktopMain) }
val watchosX64Main by getting { dependsOn(desktopMain) }
val watchosSimulatorArm64Main by getting { dependsOn(desktopMain) }

val tvosX64Main by getting { dependsOn(desktopMain) }
val tvosArm64Main by getting { dependsOn(desktopMain) }
val tvosSimulatorArm64Main by getting { dependsOn(desktopMain) }

// Test sourcesets
val commonTest by getting

val nativeTest by creating { dependsOn(commonTest) }

val macosX64Test by getting { dependsOn(nativeTest) }
val macosArm64Test by getting { dependsOn(nativeTest) }

val mingwX64Test by getting { dependsOn(nativeTest) }

val linuxX64Test by getting { dependsOn(nativeTest) }
val linuxArm64Test by getting { dependsOn(nativeTest) }

val iosX64Test by getting { dependsOn(nativeTest) }
val iosArm64Test by getting { dependsOn(nativeTest) }
val iosArm32Test by getting { dependsOn(nativeTest) }
val iosSimulatorArm64Test by getting { dependsOn(nativeTest) }

val watchosArm32Test by getting { dependsOn(nativeTest) }
val watchosArm64Test by getting { dependsOn(nativeTest) }
val watchosX86Test by getting { dependsOn(nativeTest) }
val watchosX64Test by getting { dependsOn(nativeTest) }
val watchosSimulatorArm64Test by getting { dependsOn(nativeTest) }

val tvosX64Test by getting { dependsOn(nativeTest) }
val tvosArm64Test by getting { dependsOn(nativeTest) }
val tvosSimulatorArm64Test by getting { dependsOn(nativeTest) }
}
} else {
// Make sure every project has at least one valid target, otherwise Kotlin compiler will complain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ fun Project.publishPlatformArtifactsInRootModule() {

plugins {
signing
`java-library`
`maven-publish`
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@file:Suppress("UNUSED_VARIABLE")
import org.jetbrains.kotlin.gradle.plugin.KotlinHierarchyTemplate


plugins {
id("kotlin-conventions")
Expand All @@ -7,17 +8,15 @@ plugins {
kotlin {
if (!project.hasProperty(Ci.JVM_ONLY)) {
watchosDeviceArm64()
sourceSets {

// Main source sets
val commonMain by getting {}
val desktopMain by getting { dependsOn(commonMain) }
val watchosDeviceArm64Main by getting { dependsOn(desktopMain) }

// Test sourcesets
val commonTest by getting
val nativeTest by getting { dependsOn(commonTest) }
val watchosDeviceArm64Test by getting { dependsOn(nativeTest) }
// TODO: The "desktop" intermediate source set can be integrated into "native". In this case
// the following block can be replaced with `applyDefaultHierarchyTemplate()`.
applyHierarchyTemplate(KotlinHierarchyTemplate.default) {
group("common") {
group("desktop") {
withNative()
}
}
}
} else {
// Make sure every project has at least one valid target, otherwise Kotlin compiler will complain
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
`java-library`
kotlin("multiplatform")
id("com.adarshr.test-logger")
}

repositories {
mavenCentral()
mavenLocal()
maven("https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental")
maven("https://oss.sonatype.org/content/repositories/snapshots/")
google()
gradlePluginPortal() // tvOS builds need to be able to fetch a kotlin gradle plugin
Expand All @@ -32,8 +34,6 @@ tasks.withType<KotlinCompile>().configureEach {
"-opt-in=io.kotest.common.KotestInternal",
"-opt-in=io.kotest.common.ExperimentalKotest",
)
apiVersion = "1.8"
languageVersion = "1.8"
compilerOptions.jvmTarget.set(JvmTarget.JVM_1_8)
}
}
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ json-path = "2.9.0"
junit4 = "4.13.2"
junit-platform = "1.8.2"
junit-jupiter = "5.8.2"
kotlin = "1.8.10"
kotlinx-coroutines = "1.7.0"
kotlinx-serialization = "1.3.3"
kotlin = "1.9.23"
kotlinx-coroutines = "1.8.0"
kotlinx-serialization = "1.6.3"
ktor = "1.6.8"
mockserver-netty = "5.15.0"
mockk = "1.13.10"
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 2a61950

Please sign in to comment.