Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support all K/N targets and Wasm #281

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
fail-fast: false
matrix:
os: [ 'ubuntu-latest' ]
target: [ 'jvm', 'jvm11', 'jvm17', 'jvm21', 'js', 'native' ]
target: [ 'jvm', 'jvm11', 'jvm17', 'jvm21', 'jsAndWasm', 'native' ]
include:
- os: 'macos-latest'
target: 'macos'
Expand All @@ -49,8 +49,11 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-gradle

- run: ./gradlew ${{ matrix.target }}Test --continue
timeout-minutes: 30
- if: ${{ matrix.os != 'windows-latest' }}
run: ./gradlew ${{ matrix.target }}Test --continue

- if: ${{ matrix.os == 'windows-latest' }}
run: ./gradlew ${{ matrix.target }}Test --continue --max-workers=1

- if: always() && !cancelled()
uses: actions/upload-artifact@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.gradle.*
import org.jetbrains.kotlin.gradle.plugin.*
import org.jetbrains.kotlin.gradle.plugin.mpp.*
import org.jetbrains.kotlin.gradle.targets.js.ir.*
import org.jetbrains.kotlin.gradle.targets.js.testing.*
import org.jetbrains.kotlin.gradle.targets.jvm.*
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.*
import org.jetbrains.kotlin.gradle.targets.native.tasks.*
Expand All @@ -32,15 +33,23 @@ plugins {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
kotlin {
compilerOptions {
// because of INVISIBLE_REFERENCE suppression - will be removed after migration to kotlinx.io
if (project.name != "rsocket-test") {
allWarningsAsErrors.set(true)
}
allWarningsAsErrors.set(true)
progressiveMode.set(true)
freeCompilerArgs.add("-Xrender-internal-diagnostic-names")
optIn.addAll(OptIns.ExperimentalSubclassOptIn)
}

applyDefaultHierarchyTemplate {
common {
group("nonJvm") {
withJs()
withWasmJs()
withWasmWasi()
group("native")
}
}
}

sourceSets.configureEach {
languageSettings {
if (name.contains("test", ignoreCase = true)) {
Expand Down Expand Up @@ -103,6 +112,12 @@ registerTestAggregationTask(
targetFilter = { it.platformType == KotlinPlatformType.jvm }
)

registerTestAggregationTask(
name = "jsAndWasmTest",
taskDependencies = { tasks.withType<KotlinJsTest>() },
targetFilter = { it.platformType == KotlinPlatformType.js || it.platformType == KotlinPlatformType.wasm }
)

registerTestAggregationTask(
name = "nativeTest",
taskDependencies = { tasks.withType<KotlinNativeTest>().matching { it.enabled } },
Expand Down
47 changes: 35 additions & 12 deletions build-logic/src/main/kotlin/rsocketbuild/targets.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,17 @@ package rsocketbuild

import org.gradle.jvm.toolchain.*
import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.*
import org.jetbrains.kotlin.gradle.dsl.*

fun KotlinMultiplatformExtension.allTargets() {
jvmTarget()
jsTarget()
wasmJsTarget()
wasmWasiTarget()
nativeTargets()
}

fun KotlinMultiplatformExtension.appleTargets() {
macosX64()
macosArm64()
Expand All @@ -32,29 +41,25 @@ fun KotlinMultiplatformExtension.appleTargets() {
watchosArm32()
watchosArm64()
watchosSimulatorArm64()
// https://youtrack.jetbrains.com/issue/KTOR-6368, supported by kotlinx-io
// watchosDeviceArm64()
watchosDeviceArm64()

tvosX64()
tvosArm64()
tvosSimulatorArm64()
}

fun KotlinMultiplatformExtension.nixTargets() {
fun KotlinMultiplatformExtension.nativeTargets() {
appleTargets()

linuxX64()
linuxArm64()
}

fun KotlinMultiplatformExtension.nativeTargets() {
nixTargets()
mingwX64()

// not supported by ktor, supported by kotlinx-io
// androidNativeX64()
// androidNativeX86()
// androidNativeArm64()
// androidNativeArm32()
// TODO: there are some issues with androidNative targets with Kotlin 2.1.0
// androidNativeX64()
// androidNativeX86()
// androidNativeArm64()
// androidNativeArm32()
}

fun KotlinMultiplatformExtension.jsTarget(
Expand All @@ -67,6 +72,24 @@ fun KotlinMultiplatformExtension.jsTarget(
}
}

@OptIn(ExperimentalWasmDsl::class)
fun KotlinMultiplatformExtension.wasmJsTarget(
supportsNode: Boolean = true,
supportsBrowser: Boolean = true,
) {
wasmJs {
if (supportsNode) nodejs()
if (supportsBrowser) browser()
}
}

@OptIn(ExperimentalWasmDsl::class)
fun KotlinMultiplatformExtension.wasmWasiTarget() {
wasmWasi {
nodejs()
}
}

fun KotlinMultiplatformExtension.jvmTarget(
jdkVersion: Int = 8,
jdkAdditionalTestVersions: Set<Int> = setOf(11, 17, 21),
Expand Down
1 change: 1 addition & 0 deletions ktor-plugins/ktor-client-rsocket/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ description = "rsocket-kotlin ktor client plugin"
kotlin {
jvmTarget()
jsTarget()
wasmJsTarget()
nativeTargets()

sourceSets {
Expand Down
2 changes: 1 addition & 1 deletion ktor-plugins/ktor-server-rsocket/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ description = "rsocket-kotlin ktor server plugin"

kotlin {
jvmTarget()
nixTargets()
nativeTargets()

sourceSets {
commonMain.dependencies {
Expand Down
1 change: 1 addition & 0 deletions ktor-plugins/rsocket-ktor-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ description = "OLD ARTIFACT - migrate to ktor-client-rsocket"
kotlin {
jvmTarget()
jsTarget()
wasmJsTarget()
nativeTargets()

sourceSets {
Expand Down
2 changes: 1 addition & 1 deletion ktor-plugins/rsocket-ktor-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ description = "OLD ARTIFACT - migrate to ktor-server-rsocket"

kotlin {
jvmTarget()
nixTargets()
nativeTargets()

sourceSets {
commonMain.dependencies {
Expand Down
4 changes: 1 addition & 3 deletions rsocket-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ plugins {
description = "rsocket-kotlin core functionality"

kotlin {
jvmTarget()
jsTarget()
nativeTargets()
allTargets()

sourceSets {
commonMain.dependencies {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2022 the original author or authors.
* Copyright 2015-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,5 +19,5 @@ package io.rsocket.kotlin.logging
import io.rsocket.kotlin.*

@RSocketLoggingApi
public actual val DefaultLoggerFactory: LoggerFactory
internal actual val DefaultLoggerFactory: LoggerFactory
get() = PrintLogger
4 changes: 1 addition & 3 deletions rsocket-internal-io/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ plugins {
description = "rsocket-kotlin internal IO support"

kotlin {
jvmTarget()
jsTarget()
nativeTargets()
allTargets()

sourceSets {
commonMain.dependencies {
Expand Down
4 changes: 1 addition & 3 deletions rsocket-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ plugins {

@OptIn(ExperimentalKotlinGradlePluginApi::class)
kotlin {
jvmTarget()
jsTarget()
nativeTargets()
allTargets()

compilerOptions {
freeCompilerArgs.add("-Xexpect-actual-classes")
Expand Down
27 changes: 27 additions & 0 deletions rsocket-test/src/wasmJsMain/kotlin/io/rsocket/kotlin/test/Test.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2015-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.rsocket.kotlin.test

import kotlinx.coroutines.*

actual annotation class IgnoreJs
actual annotation class IgnoreJvm
actual annotation class IgnoreNative

actual val anotherDispatcher: CoroutineDispatcher get() = Dispatchers.Default

actual fun identityHashCode(instance: Any): Int = instance.hashCode()
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2015-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.rsocket.kotlin.test

import kotlinx.coroutines.*

actual annotation class IgnoreJs
actual annotation class IgnoreJvm
actual annotation class IgnoreNative

actual val anotherDispatcher: CoroutineDispatcher get() = Dispatchers.Default

actual fun identityHashCode(instance: Any): Int = instance.hashCode()
4 changes: 1 addition & 3 deletions rsocket-transport-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ plugins {

@OptIn(ExperimentalKotlinGradlePluginApi::class)
kotlin {
jvmTarget()
jsTarget()
nativeTargets()
allTargets()

compilerOptions {
optIn.addAll(
Expand Down
Loading
Loading