Skip to content

Commit cd83301

Browse files
authored
Update Ktor to 3.1.0 and add support for all native and wasm targets (#281)
* Use "127.0.0.1" instead of "0.0.0.0" in ktor tcp server tests because of mingw/windows behaviour * leave only buffered local tests (as those will be default in future)
1 parent 43cc2b7 commit cd83301

File tree

41 files changed

+180
-265
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+180
-265
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
fail-fast: false
3434
matrix:
3535
os: [ 'ubuntu-latest' ]
36-
target: [ 'jvm', 'jvm11', 'jvm17', 'jvm21', 'js', 'native' ]
36+
target: [ 'jvm', 'jvm11', 'jvm17', 'jvm21', 'web', 'native' ]
3737
include:
3838
- os: 'macos-latest'
3939
target: 'macos'
@@ -50,7 +50,6 @@ jobs:
5050
- uses: ./.github/actions/setup-gradle
5151

5252
- run: ./gradlew ${{ matrix.target }}Test --continue
53-
timeout-minutes: 30
5453

5554
- if: always() && !cancelled()
5655
uses: actions/upload-artifact@v4

build-logic/src/main/kotlin/rsocketbuild.multiplatform-base.gradle.kts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.gradle.*
1818
import org.jetbrains.kotlin.gradle.plugin.*
1919
import org.jetbrains.kotlin.gradle.plugin.mpp.*
2020
import org.jetbrains.kotlin.gradle.targets.js.ir.*
21+
import org.jetbrains.kotlin.gradle.targets.js.testing.*
2122
import org.jetbrains.kotlin.gradle.targets.jvm.*
2223
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.*
2324
import org.jetbrains.kotlin.gradle.targets.native.tasks.*
@@ -32,15 +33,30 @@ plugins {
3233
@OptIn(ExperimentalKotlinGradlePluginApi::class)
3334
kotlin {
3435
compilerOptions {
35-
// because of INVISIBLE_REFERENCE suppression - will be removed after migration to kotlinx.io
36-
if (project.name != "rsocket-test") {
37-
allWarningsAsErrors.set(true)
38-
}
36+
allWarningsAsErrors.set(true)
3937
progressiveMode.set(true)
4038
freeCompilerArgs.add("-Xrender-internal-diagnostic-names")
4139
optIn.addAll(OptIns.ExperimentalSubclassOptIn)
4240
}
4341

42+
applyDefaultHierarchyTemplate {
43+
common {
44+
group("nonJvm") {
45+
group("nonConcurrent")
46+
group("native")
47+
}
48+
group("concurrent") {
49+
withJvm()
50+
group("native")
51+
}
52+
group("nonConcurrent") {
53+
withJs()
54+
withWasmJs()
55+
withWasmWasi()
56+
}
57+
}
58+
}
59+
4460
sourceSets.configureEach {
4561
languageSettings {
4662
if (name.contains("test", ignoreCase = true)) {
@@ -103,6 +119,12 @@ registerTestAggregationTask(
103119
targetFilter = { it.platformType == KotlinPlatformType.jvm }
104120
)
105121

122+
registerTestAggregationTask(
123+
name = "webTest",
124+
taskDependencies = { tasks.withType<KotlinJsTest>() },
125+
targetFilter = { it.platformType == KotlinPlatformType.js || it.platformType == KotlinPlatformType.wasm }
126+
)
127+
106128
registerTestAggregationTask(
107129
name = "nativeTest",
108130
taskDependencies = { tasks.withType<KotlinNativeTest>().matching { it.enabled } },

build-logic/src/main/kotlin/rsocketbuild/targets.kt

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,9 +18,21 @@ package rsocketbuild
1818

1919
import org.gradle.jvm.toolchain.*
2020
import org.gradle.kotlin.dsl.*
21+
import org.jetbrains.kotlin.gradle.*
2122
import org.jetbrains.kotlin.gradle.dsl.*
2223

23-
fun KotlinMultiplatformExtension.appleTargets() {
24+
fun KotlinMultiplatformExtension.allTargets(
25+
supportsWasi: Boolean = true,
26+
supportsBrowser: Boolean = true,
27+
) {
28+
jvmTarget()
29+
jsTarget(supportsBrowser = supportsBrowser)
30+
wasmJsTarget(supportsBrowser = supportsBrowser)
31+
if (supportsWasi) wasmWasiTarget()
32+
nativeTargets()
33+
}
34+
35+
fun KotlinMultiplatformExtension.nativeTargets() {
2436
macosX64()
2537
macosArm64()
2638

@@ -32,29 +44,20 @@ fun KotlinMultiplatformExtension.appleTargets() {
3244
watchosArm32()
3345
watchosArm64()
3446
watchosSimulatorArm64()
35-
// https://youtrack.jetbrains.com/issue/KTOR-6368, supported by kotlinx-io
36-
// watchosDeviceArm64()
47+
watchosDeviceArm64()
3748

3849
tvosX64()
3950
tvosArm64()
4051
tvosSimulatorArm64()
41-
}
4252

43-
fun KotlinMultiplatformExtension.nixTargets() {
44-
appleTargets()
4553
linuxX64()
4654
linuxArm64()
47-
}
48-
49-
fun KotlinMultiplatformExtension.nativeTargets() {
50-
nixTargets()
5155
mingwX64()
5256

53-
// not supported by ktor, supported by kotlinx-io
54-
// androidNativeX64()
55-
// androidNativeX86()
56-
// androidNativeArm64()
57-
// androidNativeArm32()
57+
androidNativeX64()
58+
androidNativeX86()
59+
androidNativeArm64()
60+
androidNativeArm32()
5861
}
5962

6063
fun KotlinMultiplatformExtension.jsTarget(
@@ -67,6 +70,24 @@ fun KotlinMultiplatformExtension.jsTarget(
6770
}
6871
}
6972

73+
@OptIn(ExperimentalWasmDsl::class)
74+
fun KotlinMultiplatformExtension.wasmJsTarget(
75+
supportsNode: Boolean = true,
76+
supportsBrowser: Boolean = true,
77+
) {
78+
wasmJs {
79+
if (supportsNode) nodejs()
80+
if (supportsBrowser) browser()
81+
}
82+
}
83+
84+
@OptIn(ExperimentalWasmDsl::class)
85+
fun KotlinMultiplatformExtension.wasmWasiTarget() {
86+
wasmWasi {
87+
nodejs()
88+
}
89+
}
90+
7091
fun KotlinMultiplatformExtension.jvmTarget(
7192
jdkVersion: Int = 8,
7293
jdkAdditionalTestVersions: Set<Int> = setOf(11, 17, 21),

build-settings/src/main/kotlin/rsocketsettings.repositories.settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ kotlinx-coroutines = "1.10.1"
77
kotlinx-benchmark = "0.4.8"
88
kotlinx-bcv = "0.17.0"
99

10-
ktor = "3.0.3"
10+
ktor = "3.1.0"
1111

1212
netty = "4.1.117.Final"
1313
netty-quic = "0.0.70.Final"

ktor-plugins/ktor-client-rsocket/build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,9 +23,9 @@ plugins {
2323
description = "rsocket-kotlin ktor client plugin"
2424

2525
kotlin {
26-
jvmTarget()
27-
jsTarget()
28-
nativeTargets()
26+
allTargets(
27+
supportsWasi = false,
28+
)
2929

3030
sourceSets {
3131
commonMain.dependencies {

ktor-plugins/ktor-server-rsocket/build.gradle.kts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ plugins {
2323
description = "rsocket-kotlin ktor server plugin"
2424

2525
kotlin {
26-
jvmTarget()
27-
nixTargets()
26+
allTargets(
27+
supportsWasi = false,
28+
supportsBrowser = false
29+
)
2830

2931
sourceSets {
3032
commonMain.dependencies {

ktor-plugins/ktor-tests/build.gradle.kts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ plugins {
2121
}
2222

2323
kotlin {
24-
jvmTarget()
25-
nixTargets()
24+
allTargets(
25+
supportsWasi = false,
26+
supportsBrowser = false
27+
)
2628

2729
sourceSets {
2830
commonTest.dependencies {

ktor-plugins/ktor-tests/src/commonTest/kotlin/io/rsocket/kotlin/ktor/tests/WebSocketConnectionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ class WebSocketConnectionTest : SuspendTest {
7676
}
7777

7878
override suspend fun before() {
79-
server.start()
79+
server.startSuspend()
8080
delay(1000)
8181
}
8282

8383
override suspend fun after() {
84-
server.stop()
84+
server.stopSuspend()
8585
client.coroutineContext.job.cancelAndJoin()
8686
}
8787

ktor-plugins/rsocket-ktor-client/build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,9 +23,9 @@ plugins {
2323
description = "OLD ARTIFACT - migrate to ktor-client-rsocket"
2424

2525
kotlin {
26-
jvmTarget()
27-
jsTarget()
28-
nativeTargets()
26+
allTargets(
27+
supportsWasi = false,
28+
)
2929

3030
sourceSets {
3131
commonMain.dependencies {

ktor-plugins/rsocket-ktor-server/build.gradle.kts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,8 +23,10 @@ plugins {
2323
description = "OLD ARTIFACT - migrate to ktor-server-rsocket"
2424

2525
kotlin {
26-
jvmTarget()
27-
nixTargets()
26+
allTargets(
27+
supportsWasi = false,
28+
supportsBrowser = false
29+
)
2830

2931
sourceSets {
3032
commonMain.dependencies {

rsocket-core/build.gradle.kts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,9 +24,7 @@ plugins {
2424
description = "rsocket-kotlin core functionality"
2525

2626
kotlin {
27-
jvmTarget()
28-
jsTarget()
29-
nativeTargets()
27+
allTargets()
3028

3129
sourceSets {
3230
commonMain.dependencies {

rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/internal/RSocketRequesterTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package io.rsocket.kotlin.internal
1818

1919
import io.rsocket.kotlin.*
2020
import io.rsocket.kotlin.frame.*
21+
import io.rsocket.kotlin.internal.io.*
2122
import io.rsocket.kotlin.keepalive.*
2223
import io.rsocket.kotlin.payload.*
2324
import io.rsocket.kotlin.test.*
@@ -102,7 +103,7 @@ class RSocketRequesterTest : TestWithConnection() {
102103
val flow = requester.requestStream(Payload.Empty).take(2).flowOn(PrefetchStrategy(1, 0))
103104

104105
expectNoEventsIn(200)
105-
flow.launchIn(connection + anotherDispatcher)
106+
flow.launchIn(connection + Dispatchers.IoCompatible)
106107

107108
awaitFrame { frame ->
108109
assertTrue(frame is RequestFrame)

rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/transport/internal/PrioritizationFrameQueueTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

1717
package io.rsocket.kotlin.transport.internal
1818

19+
import io.rsocket.kotlin.internal.io.*
1920
import io.rsocket.kotlin.test.*
2021
import kotlinx.coroutines.*
2122
import kotlinx.coroutines.channels.*
@@ -62,7 +63,7 @@ class PrioritizationFrameQueueTest : SuspendTest {
6263
@Test
6364
fun testAsyncReceive() = test {
6465
val deferred = CompletableDeferred<Source?>()
65-
launch(anotherDispatcher) {
66+
launch(Dispatchers.IoCompatible) {
6667
deferred.complete(queue.dequeueFrame())
6768
}
6869
delay(100)

0 commit comments

Comments
 (0)