diff --git a/build-logic/src/main/kotlin/rsocketbuild.multiplatform-base.gradle.kts b/build-logic/src/main/kotlin/rsocketbuild.multiplatform-base.gradle.kts new file mode 100644 index 00000000..e0b3afd1 --- /dev/null +++ b/build-logic/src/main/kotlin/rsocketbuild.multiplatform-base.gradle.kts @@ -0,0 +1,132 @@ +/* + * 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. + */ + +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.jvm.* +import org.jetbrains.kotlin.gradle.targets.jvm.tasks.* +import org.jetbrains.kotlin.gradle.targets.native.tasks.* +import org.jetbrains.kotlin.gradle.tasks.* +import rsocketbuild.* +import rsocketbuild.tests.* + +plugins { + kotlin("multiplatform") +} + +@OptIn(ExperimentalKotlinGradlePluginApi::class) +kotlin { + compilerOptions { + // allWarningsAsErrors.set(true) + progressiveMode.set(true) + freeCompilerArgs.add("-Xrender-internal-diagnostic-names") + } + + sourceSets.configureEach { + languageSettings { + if (name.contains("test", ignoreCase = true)) { + optIn(OptIns.ExperimentalStdlibApi) + optIn(OptIns.DelicateCoroutinesApi) + + // rsocket related + optIn(OptIns.TransportApi) + optIn(OptIns.ExperimentalMetadataApi) + optIn(OptIns.ExperimentalStreamsApi) + optIn(OptIns.RSocketLoggingApi) + } + } + } + + targets.withType().configureEach { + compilations.configureEach { + compilerOptions.configure { + freeCompilerArgs.add("-Xjvm-default=all") + } + } + } + + // revisit JS block after WASM support + targets.withType().configureEach { + whenBrowserConfigured { + testTask { + useKarma { + useConfigDirectory(rootDir.resolve("gradle/js/karma.config.d")) + useChromeHeadless() + } + } + } + whenNodejsConfigured { + testTask { + useMocha { + timeout = "600s" + } + } + } + } + + //setup tests running in RELEASE mode + targets.withType().configureEach { + binaries.test(listOf(NativeBuildType.RELEASE)) + } + targets.withType>().configureEach { + testRuns.create("releaseTest") { + setExecutionSourceFrom(binaries.getTest(NativeBuildType.RELEASE)) + } + } +} + +// for CI mainly + +registerTestAggregationTask( + name = "jvmAllTest", + taskDependencies = { tasks.withType() }, + targetFilter = { it.platformType == KotlinPlatformType.jvm } +) + +registerTestAggregationTask( + name = "nativeTest", + taskDependencies = { tasks.withType().matching { it.enabled } }, + targetFilter = { it.platformType == KotlinPlatformType.native } +) + +listOf("ios", "watchos", "tvos", "macos").forEach { targetGroup -> + registerTestAggregationTask( + name = "${targetGroup}Test", + taskDependencies = { + tasks.withType().matching { + it.enabled && it.name.startsWith(targetGroup, ignoreCase = true) + } + }, + targetFilter = { + it.platformType == KotlinPlatformType.native && it.name.startsWith(targetGroup, ignoreCase = true) + } + ) +} + +// on build, link even those binaries, which it's not possible to run +tasks.build { + dependsOn(tasks.withType()) +} + +if (providers.gradleProperty("rsocketbuild.skipTests").map(String::toBoolean).getOrElse(false)) { + tasks.withType().configureEach { onlyIf { false } } +} + +if (providers.gradleProperty("rsocketbuild.skipNativeLink").map(String::toBoolean).getOrElse(false)) { + tasks.withType().configureEach { onlyIf { false } } +} diff --git a/build-logic/src/main/kotlin/rsocketbuild.target.native.all.gradle.kts b/build-logic/src/main/kotlin/rsocketbuild.multiplatform-library.gradle.kts similarity index 87% rename from build-logic/src/main/kotlin/rsocketbuild.target.native.all.gradle.kts rename to build-logic/src/main/kotlin/rsocketbuild.multiplatform-library.gradle.kts index f0613a78..9c8d4612 100644 --- a/build-logic/src/main/kotlin/rsocketbuild.target.native.all.gradle.kts +++ b/build-logic/src/main/kotlin/rsocketbuild.multiplatform-library.gradle.kts @@ -15,9 +15,10 @@ */ plugins { - id("rsocketbuild.target.native.nix") + id("rsocketbuild.multiplatform-base") + id("rsocketbuild.publication") } kotlin { - mingwX64() + explicitApi() } diff --git a/build-logic/src/main/kotlin/rsocketbuild.multiplatform.gradle.kts b/build-logic/src/main/kotlin/rsocketbuild.multiplatform.gradle.kts deleted file mode 100644 index 30189e90..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.multiplatform.gradle.kts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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. - */ - -import org.jetbrains.kotlin.gradle.tasks.* - -plugins { - kotlin("multiplatform") -} - -kotlin { - jvmToolchain(8) - - targets.configureEach { - compilations.configureEach { - compilerOptions.configure { - freeCompilerArgs.add("-Xrender-internal-diagnostic-names") - } - } - } - - sourceSets.configureEach { - languageSettings { - progressiveMode = true - if (name.contains("test", ignoreCase = true)) optInForTest() - } - } -} - - -if (providers.gradleProperty("rsocketbuild.skipTests").map(String::toBoolean).getOrElse(false)) { - tasks.withType().configureEach { onlyIf { false } } -} - -if (providers.gradleProperty("rsocketbuild.skipNativeLink").map(String::toBoolean).getOrElse(false)) { - tasks.withType().configureEach { onlyIf { false } } -} diff --git a/build-logic/src/main/kotlin/rsocketbuild.multiplatform.native.gradle.kts b/build-logic/src/main/kotlin/rsocketbuild.multiplatform.native.gradle.kts deleted file mode 100644 index 55178c5f..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.multiplatform.native.gradle.kts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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. - */ - -import org.jetbrains.kotlin.gradle.plugin.mpp.* - -plugins { - id("rsocketbuild.multiplatform") -} - -kotlin { - targets.configureEach { - //add another test task with release binary - if (this is KotlinNativeTargetWithTests<*>) { - binaries.test(listOf(NativeBuildType.RELEASE)) - testRuns.create("releaseTest") { - setExecutionSourceFrom(binaries.getTest(NativeBuildType.RELEASE)) - } - } - } -} diff --git a/build-logic/src/main/kotlin/rsocketbuild.target.all.gradle.kts b/build-logic/src/main/kotlin/rsocketbuild.target.all.gradle.kts deleted file mode 100644 index c71ee074..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.target.all.gradle.kts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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. - */ - -plugins { - id("rsocketbuild.target.js.all") - id("rsocketbuild.target.jvm") - id("rsocketbuild.target.native.all") -} diff --git a/build-logic/src/main/kotlin/rsocketbuild.target.js.all.gradle.kts b/build-logic/src/main/kotlin/rsocketbuild.target.js.all.gradle.kts deleted file mode 100644 index 962bd3d0..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.target.js.all.gradle.kts +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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. - */ - -plugins { - id("rsocketbuild.target.js.browser") - id("rsocketbuild.target.js.node") -} diff --git a/build-logic/src/main/kotlin/rsocketbuild.target.js.browser.gradle.kts b/build-logic/src/main/kotlin/rsocketbuild.target.js.browser.gradle.kts deleted file mode 100644 index 5d6d51c3..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.target.js.browser.gradle.kts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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. - */ - -plugins { - id("rsocketbuild.multiplatform") -} - -kotlin { - js { - browser { - testTask { - useKarma { - useConfigDirectory(rootDir.resolve("gradle/js/karma.config.d")) - useChromeHeadless() - } - } - } - } -} diff --git a/build-logic/src/main/kotlin/rsocketbuild.target.js.node.gradle.kts b/build-logic/src/main/kotlin/rsocketbuild.target.js.node.gradle.kts deleted file mode 100644 index e610de61..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.target.js.node.gradle.kts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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. - */ - -plugins { - id("rsocketbuild.multiplatform") -} - -kotlin { - js { - nodejs { - testTask { - useMocha { - timeout = "600s" - } - } - } - } -} diff --git a/build-logic/src/main/kotlin/rsocketbuild.target.jvm.gradle.kts b/build-logic/src/main/kotlin/rsocketbuild.target.jvm.gradle.kts deleted file mode 100644 index cb23fc3a..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.target.jvm.gradle.kts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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. - */ - -import org.jetbrains.kotlin.gradle.targets.jvm.tasks.* - -plugins { - id("rsocketbuild.multiplatform") -} - -kotlin { - jvm { - listOf(11, 17, 21).forEach { jdkVersion -> - testRuns.create("${jdkVersion}Test") { - executionTask.configure { - javaLauncher.set( - javaToolchains.launcherFor { - languageVersion.set(JavaLanguageVersion.of(jdkVersion)) - } - ) - } - } - } - testRuns.configureEach { - executionTask.configure { - // ActiveProcessorCount is used here, to make sure local setup is similar as on CI - // GitHub Actions linux runners have 2 cores - jvmArgs("-Xmx1g", "-XX:ActiveProcessorCount=2") - } - } - } -} - -tasks.register("jvmAllTest") { - group = "verification" - dependsOn(tasks.withType()) -} diff --git a/build-logic/src/main/kotlin/rsocketbuild.target.native.nix.gradle.kts b/build-logic/src/main/kotlin/rsocketbuild.target.native.nix.gradle.kts deleted file mode 100644 index 51a13159..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.target.native.nix.gradle.kts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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. - */ - -plugins { - id("rsocketbuild.target.native.apple") -} - -kotlin { - linuxX64() -} diff --git a/build-logic/src/main/kotlin/rsocketbuild.template.library.gradle.kts b/build-logic/src/main/kotlin/rsocketbuild.template.library.gradle.kts deleted file mode 100644 index 6e1c447f..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.template.library.gradle.kts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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. - */ - -plugins { - id("rsocketbuild.multiplatform") - id("rsocketbuild.publication") -} - -kotlin { - explicitApi() - - sourceSets { - commonTest { - dependencies { - implementation(project(":rsocket-test")) - } - } - } -} diff --git a/build-logic/src/main/kotlin/rsocketbuild.template.test.gradle.kts b/build-logic/src/main/kotlin/rsocketbuild.template.test.gradle.kts deleted file mode 100644 index b608ff83..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.template.test.gradle.kts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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. - */ - -plugins { - id("rsocketbuild.multiplatform") -} - -kotlin { - sourceSets.configureEach { - languageSettings.optInForTest() - } -} diff --git a/build-logic/src/main/kotlin/rsocketbuild.template.transport.gradle.kts b/build-logic/src/main/kotlin/rsocketbuild.template.transport.gradle.kts deleted file mode 100644 index 32fc1b2a..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.template.transport.gradle.kts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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. - */ - -plugins { - id("rsocketbuild.template.library") -} - -kotlin { - sourceSets { - commonTest { - dependencies { - implementation(project(":rsocket-transport-tests")) - } - } - } -} diff --git a/build-logic/src/main/kotlin/rsocketbuild.target.native.apple.gradle.kts b/build-logic/src/main/kotlin/rsocketbuild/OptIns.kt similarity index 50% rename from build-logic/src/main/kotlin/rsocketbuild.target.native.apple.gradle.kts rename to build-logic/src/main/kotlin/rsocketbuild/OptIns.kt index 52619b46..aa9e7229 100644 --- a/build-logic/src/main/kotlin/rsocketbuild.target.native.apple.gradle.kts +++ b/build-logic/src/main/kotlin/rsocketbuild/OptIns.kt @@ -14,25 +14,16 @@ * limitations under the License. */ -plugins { - id("rsocketbuild.multiplatform.native") -} - -kotlin { - macosX64() - macosArm64() - - iosArm64() - iosX64() - iosSimulatorArm64() +package rsocketbuild - tvosArm64() - tvosX64() - tvosSimulatorArm64() +@Suppress("ConstPropertyName") +object OptIns { + const val ExperimentalStdlibApi = "kotlin.ExperimentalStdlibApi" + const val ExperimentalCoroutinesApi = "kotlinx.coroutines.ExperimentalCoroutinesApi" + const val DelicateCoroutinesApi = "kotlinx.coroutines.DelicateCoroutinesApi" - //TODO: after coroutines 1.7.0 add watchosDeviceArm64() - watchosArm32() - watchosArm64() - watchosX64() - watchosSimulatorArm64() + const val TransportApi = "io.rsocket.kotlin.TransportApi" + const val ExperimentalMetadataApi = "io.rsocket.kotlin.ExperimentalMetadataApi" + const val ExperimentalStreamsApi = "io.rsocket.kotlin.ExperimentalStreamsApi" + const val RSocketLoggingApi = "io.rsocket.kotlin.RSocketLoggingApi" } diff --git a/build-logic/src/main/kotlin/rsocketbuild/targets.kt b/build-logic/src/main/kotlin/rsocketbuild/targets.kt new file mode 100644 index 00000000..3ef9d40e --- /dev/null +++ b/build-logic/src/main/kotlin/rsocketbuild/targets.kt @@ -0,0 +1,87 @@ +/* + * 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 rsocketbuild + +import org.gradle.jvm.toolchain.* +import org.gradle.kotlin.dsl.* +import org.jetbrains.kotlin.gradle.dsl.* + +fun KotlinMultiplatformExtension.appleTargets() { + macosX64() + macosArm64() + + iosArm64() + iosX64() + iosSimulatorArm64() + + watchosX64() + watchosArm32() + watchosArm64() + watchosSimulatorArm64() + // https://youtrack.jetbrains.com/issue/KTOR-6368, supported by kotlinx-io + // watchosDeviceArm64() + + tvosX64() + tvosArm64() + tvosSimulatorArm64() +} + +fun KotlinMultiplatformExtension.nixTargets() { + appleTargets() + linuxX64() + linuxArm64() +} + +fun KotlinMultiplatformExtension.nativeTargets() { + nixTargets() + mingwX64() + + // not supported by ktor, supported by kotlinx-io + // androidNativeX64() + // androidNativeX86() + // androidNativeArm64() + // androidNativeArm32() +} + +fun KotlinMultiplatformExtension.jsTarget( + supportsNode: Boolean = true, + supportsBrowser: Boolean = true, +) { + js { + if (supportsNode) nodejs() + if (supportsBrowser) browser() + } +} + +fun KotlinMultiplatformExtension.jvmTarget( + jdkVersion: Int = 8, + jdkAdditionalTestVersions: Set = setOf(11, 17, 21), +) { + jvmToolchain(jdkVersion) + jvm { + val javaToolchains = project.extensions.getByName("javaToolchains") + jdkAdditionalTestVersions.forEach { jdkTestVersion -> + testRuns.create("${jdkTestVersion}Test") { + executionTask.configure { + javaLauncher.set(javaToolchains.launcherFor { + languageVersion.set(JavaLanguageVersion.of(jdkTestVersion)) + }) + } + } + } + } +} diff --git a/build-logic/src/main/kotlin/TestOptIn.kt b/build-logic/src/main/kotlin/rsocketbuild/tests/TestAggregation.kt similarity index 50% rename from build-logic/src/main/kotlin/TestOptIn.kt rename to build-logic/src/main/kotlin/rsocketbuild/tests/TestAggregation.kt index 5bae2553..b7b75200 100644 --- a/build-logic/src/main/kotlin/TestOptIn.kt +++ b/build-logic/src/main/kotlin/rsocketbuild/tests/TestAggregation.kt @@ -14,21 +14,28 @@ * limitations under the License. */ -import org.jetbrains.kotlin.gradle.plugin.* +package rsocketbuild.tests -//TODO may be remove part of annotations -fun LanguageSettingsBuilder.optInForTest() { - optIn("kotlin.time.ExperimentalTime") - optIn("kotlin.ExperimentalStdlibApi") +import org.gradle.api.* +import org.gradle.api.tasks.* +import org.jetbrains.kotlin.gradle.dsl.* +import org.jetbrains.kotlin.gradle.plugin.* - optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") - optIn("kotlinx.coroutines.InternalCoroutinesApi") - optIn("kotlinx.coroutines.ObsoleteCoroutinesApi") - optIn("kotlinx.coroutines.FlowPreview") - optIn("kotlinx.coroutines.DelicateCoroutinesApi") +fun Project.registerTestAggregationTask( + name: String, + taskDependencies: () -> TaskCollection<*>, + targetFilter: (KotlinTarget) -> Boolean, +) { + extensions.configure("kotlin") { + var called = false + targets.matching(targetFilter).configureEach { + if (called) return@configureEach + called = true - optIn("io.rsocket.kotlin.TransportApi") - optIn("io.rsocket.kotlin.ExperimentalMetadataApi") - optIn("io.rsocket.kotlin.ExperimentalStreamsApi") - optIn("io.rsocket.kotlin.RSocketLoggingApi") + tasks.register(name) { + group = "verification" + dependsOn(taskDependencies()) + } + } + } } diff --git a/rsocket-core/api/rsocket-core.api b/rsocket-core/api/rsocket-core.api index 95c6e159..d1a9ac27 100644 --- a/rsocket-core/api/rsocket-core.api +++ b/rsocket-core/api/rsocket-core.api @@ -3,7 +3,6 @@ public final class io/rsocket/kotlin/ChannelStrategy : io/rsocket/kotlin/Request public fun firstRequest (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun fold (Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object; public fun get (Lkotlin/coroutines/CoroutineContext$Key;)Lkotlin/coroutines/CoroutineContext$Element; - public fun getKey ()Lkotlin/coroutines/CoroutineContext$Key; public fun minusKey (Lkotlin/coroutines/CoroutineContext$Key;)Lkotlin/coroutines/CoroutineContext; public fun nextRequest (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun plus (Lkotlin/coroutines/CoroutineContext;)Lkotlin/coroutines/CoroutineContext; @@ -40,26 +39,20 @@ public final class io/rsocket/kotlin/PrefetchStrategy : io/rsocket/kotlin/Reques public fun (II)V public fun fold (Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object; public fun get (Lkotlin/coroutines/CoroutineContext$Key;)Lkotlin/coroutines/CoroutineContext$Element; - public fun getKey ()Lkotlin/coroutines/CoroutineContext$Key; public fun minusKey (Lkotlin/coroutines/CoroutineContext$Key;)Lkotlin/coroutines/CoroutineContext; public fun plus (Lkotlin/coroutines/CoroutineContext;)Lkotlin/coroutines/CoroutineContext; public fun provide ()Lio/rsocket/kotlin/RequestStrategy$Element; } public abstract interface class io/rsocket/kotlin/RSocket : kotlinx/coroutines/CoroutineScope { - public abstract fun fireAndForget (Lio/rsocket/kotlin/payload/Payload;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public abstract fun metadataPush (Lio/ktor/utils/io/core/ByteReadPacket;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public abstract fun requestChannel (Lio/rsocket/kotlin/payload/Payload;Lkotlinx/coroutines/flow/Flow;)Lkotlinx/coroutines/flow/Flow; - public abstract fun requestResponse (Lio/rsocket/kotlin/payload/Payload;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public abstract fun requestStream (Lio/rsocket/kotlin/payload/Payload;)Lkotlinx/coroutines/flow/Flow; -} - -public final class io/rsocket/kotlin/RSocket$DefaultImpls { - public static fun fireAndForget (Lio/rsocket/kotlin/RSocket;Lio/rsocket/kotlin/payload/Payload;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static fun metadataPush (Lio/rsocket/kotlin/RSocket;Lio/ktor/utils/io/core/ByteReadPacket;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static fun requestChannel (Lio/rsocket/kotlin/RSocket;Lio/rsocket/kotlin/payload/Payload;Lkotlinx/coroutines/flow/Flow;)Lkotlinx/coroutines/flow/Flow; - public static fun requestResponse (Lio/rsocket/kotlin/RSocket;Lio/rsocket/kotlin/payload/Payload;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static fun requestStream (Lio/rsocket/kotlin/RSocket;Lio/rsocket/kotlin/payload/Payload;)Lkotlinx/coroutines/flow/Flow; + public fun fireAndForget (Lio/rsocket/kotlin/payload/Payload;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun fireAndForget$suspendImpl (Lio/rsocket/kotlin/RSocket;Lio/rsocket/kotlin/payload/Payload;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun metadataPush (Lio/ktor/utils/io/core/ByteReadPacket;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun metadataPush$suspendImpl (Lio/rsocket/kotlin/RSocket;Lio/ktor/utils/io/core/ByteReadPacket;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun requestChannel (Lio/rsocket/kotlin/payload/Payload;Lkotlinx/coroutines/flow/Flow;)Lkotlinx/coroutines/flow/Flow; + public fun requestResponse (Lio/rsocket/kotlin/payload/Payload;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun requestResponse$suspendImpl (Lio/rsocket/kotlin/RSocket;Lio/rsocket/kotlin/payload/Payload;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun requestStream (Lio/rsocket/kotlin/payload/Payload;)Lkotlinx/coroutines/flow/Flow; } public abstract class io/rsocket/kotlin/RSocketError : java/lang/Throwable { @@ -144,14 +137,13 @@ public final class io/rsocket/kotlin/RSocketRequestHandlerKt { public abstract interface class io/rsocket/kotlin/RequestStrategy : kotlin/coroutines/CoroutineContext$Element { public static final field Key Lio/rsocket/kotlin/RequestStrategy$Key; - public abstract fun getKey ()Lkotlin/coroutines/CoroutineContext$Key; + public fun getKey ()Lkotlin/coroutines/CoroutineContext$Key; public abstract fun provide ()Lio/rsocket/kotlin/RequestStrategy$Element; } public final class io/rsocket/kotlin/RequestStrategy$DefaultImpls { public static fun fold (Lio/rsocket/kotlin/RequestStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object; public static fun get (Lio/rsocket/kotlin/RequestStrategy;Lkotlin/coroutines/CoroutineContext$Key;)Lkotlin/coroutines/CoroutineContext$Element; - public static fun getKey (Lio/rsocket/kotlin/RequestStrategy;)Lkotlin/coroutines/CoroutineContext$Key; public static fun minusKey (Lio/rsocket/kotlin/RequestStrategy;Lkotlin/coroutines/CoroutineContext$Key;)Lkotlin/coroutines/CoroutineContext; public static fun plus (Lio/rsocket/kotlin/RequestStrategy;Lkotlin/coroutines/CoroutineContext;)Lkotlin/coroutines/CoroutineContext; } @@ -413,16 +405,10 @@ public final class io/rsocket/kotlin/logging/PrintLogger$Companion : io/rsocket/ public abstract interface class io/rsocket/kotlin/metadata/CompositeMetadata : io/rsocket/kotlin/metadata/Metadata { public static final field Reader Lio/rsocket/kotlin/metadata/CompositeMetadata$Reader; - public abstract fun close ()V + public fun close ()V public abstract fun getEntries ()Ljava/util/List; - public abstract fun getMimeType ()Lio/rsocket/kotlin/core/MimeType; - public abstract fun writeSelf (Lio/ktor/utils/io/core/BytePacketBuilder;)V -} - -public final class io/rsocket/kotlin/metadata/CompositeMetadata$DefaultImpls { - public static fun close (Lio/rsocket/kotlin/metadata/CompositeMetadata;)V - public static fun getMimeType (Lio/rsocket/kotlin/metadata/CompositeMetadata;)Lio/rsocket/kotlin/core/MimeType; - public static fun writeSelf (Lio/rsocket/kotlin/metadata/CompositeMetadata;Lio/ktor/utils/io/core/BytePacketBuilder;)V + public fun getMimeType ()Lio/rsocket/kotlin/core/MimeType; + public fun writeSelf (Lio/ktor/utils/io/core/BytePacketBuilder;)V } public final class io/rsocket/kotlin/metadata/CompositeMetadata$Entry { @@ -468,10 +454,7 @@ public final class io/rsocket/kotlin/metadata/CompositeMetadataFromBuilder : io/ public fun ()V public fun add (Lio/rsocket/kotlin/core/MimeType;Lio/ktor/utils/io/core/ByteReadPacket;)V public fun add (Lio/rsocket/kotlin/metadata/Metadata;)V - public fun close ()V public fun getEntries ()Ljava/util/List; - public fun getMimeType ()Lio/rsocket/kotlin/core/MimeType; - public fun writeSelf (Lio/ktor/utils/io/core/BytePacketBuilder;)V } public final class io/rsocket/kotlin/metadata/CompositeMetadataKt { @@ -603,28 +586,19 @@ public final class io/rsocket/kotlin/metadata/ZipkinTracingMetadataKt { } public abstract interface class io/rsocket/kotlin/metadata/security/AuthMetadata : io/rsocket/kotlin/metadata/Metadata { - public abstract fun getMimeType ()Lio/rsocket/kotlin/core/MimeType; + public fun getMimeType ()Lio/rsocket/kotlin/core/MimeType; public abstract fun getType ()Lio/rsocket/kotlin/metadata/security/AuthType; public abstract fun writeContent (Lio/ktor/utils/io/core/BytePacketBuilder;)V - public abstract fun writeSelf (Lio/ktor/utils/io/core/BytePacketBuilder;)V -} - -public final class io/rsocket/kotlin/metadata/security/AuthMetadata$DefaultImpls { - public static fun getMimeType (Lio/rsocket/kotlin/metadata/security/AuthMetadata;)Lio/rsocket/kotlin/core/MimeType; - public static fun writeSelf (Lio/rsocket/kotlin/metadata/security/AuthMetadata;Lio/ktor/utils/io/core/BytePacketBuilder;)V + public fun writeSelf (Lio/ktor/utils/io/core/BytePacketBuilder;)V } public abstract interface class io/rsocket/kotlin/metadata/security/AuthMetadataReader : io/rsocket/kotlin/metadata/MetadataReader { - public abstract fun getMimeType ()Lio/rsocket/kotlin/core/MimeType; - public abstract fun read-sXCisgc (Lio/ktor/utils/io/core/ByteReadPacket;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/security/AuthMetadata; + public fun getMimeType ()Lio/rsocket/kotlin/core/MimeType; + public synthetic fun read-sXCisgc (Lio/ktor/utils/io/core/ByteReadPacket;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/Metadata; + public fun read-sXCisgc (Lio/ktor/utils/io/core/ByteReadPacket;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/security/AuthMetadata; public abstract fun readContent-FTxoUho (Lio/ktor/utils/io/core/ByteReadPacket;Lio/rsocket/kotlin/metadata/security/AuthType;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/security/AuthMetadata; } -public final class io/rsocket/kotlin/metadata/security/AuthMetadataReader$DefaultImpls { - public static fun getMimeType (Lio/rsocket/kotlin/metadata/security/AuthMetadataReader;)Lio/rsocket/kotlin/core/MimeType; - public static fun read-sXCisgc (Lio/rsocket/kotlin/metadata/security/AuthMetadataReader;Lio/ktor/utils/io/core/ByteReadPacket;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/security/AuthMetadata; -} - public abstract interface class io/rsocket/kotlin/metadata/security/AuthType { } @@ -640,18 +614,12 @@ public final class io/rsocket/kotlin/metadata/security/BearerAuthMetadata : io/r public static final field Reader Lio/rsocket/kotlin/metadata/security/BearerAuthMetadata$Reader; public fun (Ljava/lang/String;)V public fun close ()V - public fun getMimeType ()Lio/rsocket/kotlin/core/MimeType; public final fun getToken ()Ljava/lang/String; public fun getType ()Lio/rsocket/kotlin/metadata/security/AuthType; public fun writeContent (Lio/ktor/utils/io/core/BytePacketBuilder;)V - public fun writeSelf (Lio/ktor/utils/io/core/BytePacketBuilder;)V } public final class io/rsocket/kotlin/metadata/security/BearerAuthMetadata$Reader : io/rsocket/kotlin/metadata/security/AuthMetadataReader { - public fun getMimeType ()Lio/rsocket/kotlin/core/MimeType; - public synthetic fun read-sXCisgc (Lio/ktor/utils/io/core/ByteReadPacket;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/Metadata; - public synthetic fun read-sXCisgc (Lio/ktor/utils/io/core/ByteReadPacket;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/security/AuthMetadata; - public fun read-sXCisgc (Lio/ktor/utils/io/core/ByteReadPacket;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/security/BearerAuthMetadata; public synthetic fun readContent-FTxoUho (Lio/ktor/utils/io/core/ByteReadPacket;Lio/rsocket/kotlin/metadata/security/AuthType;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/security/AuthMetadata; public fun readContent-FTxoUho (Lio/ktor/utils/io/core/ByteReadPacket;Lio/rsocket/kotlin/metadata/security/AuthType;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/security/BearerAuthMetadata; } @@ -672,17 +640,11 @@ public final class io/rsocket/kotlin/metadata/security/RawAuthMetadata : io/rsoc public fun (Lio/rsocket/kotlin/metadata/security/AuthType;Lio/ktor/utils/io/core/ByteReadPacket;)V public fun close ()V public final fun getContent ()Lio/ktor/utils/io/core/ByteReadPacket; - public fun getMimeType ()Lio/rsocket/kotlin/core/MimeType; public fun getType ()Lio/rsocket/kotlin/metadata/security/AuthType; public fun writeContent (Lio/ktor/utils/io/core/BytePacketBuilder;)V - public fun writeSelf (Lio/ktor/utils/io/core/BytePacketBuilder;)V } public final class io/rsocket/kotlin/metadata/security/RawAuthMetadata$Reader : io/rsocket/kotlin/metadata/security/AuthMetadataReader { - public fun getMimeType ()Lio/rsocket/kotlin/core/MimeType; - public synthetic fun read-sXCisgc (Lio/ktor/utils/io/core/ByteReadPacket;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/Metadata; - public synthetic fun read-sXCisgc (Lio/ktor/utils/io/core/ByteReadPacket;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/security/AuthMetadata; - public fun read-sXCisgc (Lio/ktor/utils/io/core/ByteReadPacket;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/security/RawAuthMetadata; public synthetic fun readContent-FTxoUho (Lio/ktor/utils/io/core/ByteReadPacket;Lio/rsocket/kotlin/metadata/security/AuthType;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/security/AuthMetadata; public fun readContent-FTxoUho (Lio/ktor/utils/io/core/ByteReadPacket;Lio/rsocket/kotlin/metadata/security/AuthType;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/security/RawAuthMetadata; } @@ -710,19 +672,13 @@ public final class io/rsocket/kotlin/metadata/security/SimpleAuthMetadata : io/r public static final field Reader Lio/rsocket/kotlin/metadata/security/SimpleAuthMetadata$Reader; public fun (Ljava/lang/String;Ljava/lang/String;)V public fun close ()V - public fun getMimeType ()Lio/rsocket/kotlin/core/MimeType; public final fun getPassword ()Ljava/lang/String; public fun getType ()Lio/rsocket/kotlin/metadata/security/AuthType; public final fun getUsername ()Ljava/lang/String; public fun writeContent (Lio/ktor/utils/io/core/BytePacketBuilder;)V - public fun writeSelf (Lio/ktor/utils/io/core/BytePacketBuilder;)V } public final class io/rsocket/kotlin/metadata/security/SimpleAuthMetadata$Reader : io/rsocket/kotlin/metadata/security/AuthMetadataReader { - public fun getMimeType ()Lio/rsocket/kotlin/core/MimeType; - public synthetic fun read-sXCisgc (Lio/ktor/utils/io/core/ByteReadPacket;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/Metadata; - public synthetic fun read-sXCisgc (Lio/ktor/utils/io/core/ByteReadPacket;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/security/AuthMetadata; - public fun read-sXCisgc (Lio/ktor/utils/io/core/ByteReadPacket;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/security/SimpleAuthMetadata; public synthetic fun readContent-FTxoUho (Lio/ktor/utils/io/core/ByteReadPacket;Lio/rsocket/kotlin/metadata/security/AuthType;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/security/AuthMetadata; public fun readContent-FTxoUho (Lio/ktor/utils/io/core/ByteReadPacket;Lio/rsocket/kotlin/metadata/security/AuthType;Lio/ktor/utils/io/pool/ObjectPool;)Lio/rsocket/kotlin/metadata/security/SimpleAuthMetadata; } @@ -746,8 +702,8 @@ public final class io/rsocket/kotlin/metadata/security/WellKnowAuthType$Companio public abstract interface class io/rsocket/kotlin/payload/Payload : java/io/Closeable { public static final field Companion Lio/rsocket/kotlin/payload/Payload$Companion; - public abstract fun close ()V - public abstract fun copy ()Lio/rsocket/kotlin/payload/Payload; + public fun close ()V + public fun copy ()Lio/rsocket/kotlin/payload/Payload; public abstract fun getData ()Lio/ktor/utils/io/core/ByteReadPacket; public abstract fun getMetadata ()Lio/ktor/utils/io/core/ByteReadPacket; } @@ -756,11 +712,6 @@ public final class io/rsocket/kotlin/payload/Payload$Companion { public final fun getEmpty ()Lio/rsocket/kotlin/payload/Payload; } -public final class io/rsocket/kotlin/payload/Payload$DefaultImpls { - public static fun close (Lio/rsocket/kotlin/payload/Payload;)V - public static fun copy (Lio/rsocket/kotlin/payload/Payload;)Lio/rsocket/kotlin/payload/Payload; -} - public abstract interface class io/rsocket/kotlin/payload/PayloadBuilder : java/io/Closeable { public abstract fun data (Lio/ktor/utils/io/core/ByteReadPacket;)V public abstract fun metadata (Lio/ktor/utils/io/core/ByteReadPacket;)V @@ -779,8 +730,6 @@ public final class io/rsocket/kotlin/payload/PayloadBuilderKt { public final class io/rsocket/kotlin/payload/PayloadFromBuilder : io/rsocket/kotlin/payload/Payload, io/rsocket/kotlin/payload/PayloadBuilder { public fun ()V public final fun build ()Lio/rsocket/kotlin/payload/Payload; - public fun close ()V - public fun copy ()Lio/rsocket/kotlin/payload/Payload; public fun data (Lio/ktor/utils/io/core/ByteReadPacket;)V public fun getData ()Lio/ktor/utils/io/core/ByteReadPacket; public fun getMetadata ()Lio/ktor/utils/io/core/ByteReadPacket; @@ -804,11 +753,7 @@ public final class io/rsocket/kotlin/payload/PayloadMimeTypeKt { public abstract interface class io/rsocket/kotlin/transport/ClientTransport : kotlinx/coroutines/CoroutineScope { public abstract fun connect (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public abstract fun getCoroutineContext ()Lkotlin/coroutines/CoroutineContext; -} - -public final class io/rsocket/kotlin/transport/ClientTransport$DefaultImpls { - public static fun getCoroutineContext (Lio/rsocket/kotlin/transport/ClientTransport;)Lkotlin/coroutines/CoroutineContext; + public fun getCoroutineContext ()Lkotlin/coroutines/CoroutineContext; } public final class io/rsocket/kotlin/transport/ClientTransportKt { diff --git a/rsocket-core/build.gradle.kts b/rsocket-core/build.gradle.kts index 43cd4468..c7b99d29 100644 --- a/rsocket-core/build.gradle.kts +++ b/rsocket-core/build.gradle.kts @@ -14,28 +14,30 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { - id("rsocketbuild.template.library") - id("rsocketbuild.target.all") + id("rsocketbuild.multiplatform-library") id("kotlinx-atomicfu") } +description = "rsocket-kotlin core functionality" + kotlin { + jvmTarget() + jsTarget() + nativeTargets() + sourceSets { - commonMain { - dependencies { - implementation(projects.rsocketInternalIo) + commonMain.dependencies { + implementation(projects.rsocketInternalIo) - api(libs.kotlinx.coroutines.core) - api(libs.ktor.io) - } + api(libs.kotlinx.coroutines.core) + api(libs.ktor.io) } - commonTest { - dependencies { - implementation(projects.rsocketTransportLocal) - } + commonTest.dependencies { + implementation(projects.rsocketTest) + implementation(projects.rsocketTransportLocal) } } } - -description = "RSocket core functionality" diff --git a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/ConnectionEstablishmentTest.kt b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/ConnectionEstablishmentTest.kt index db037c66..69eee240 100644 --- a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/ConnectionEstablishmentTest.kt +++ b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/ConnectionEstablishmentTest.kt @@ -70,6 +70,7 @@ class ConnectionEstablishmentTest : SuspendTest, TestWithLeakCheck { assertEquals(errorMessage, error.message) } connection.coroutineContext.job.join() + @OptIn(InternalCoroutinesApi::class) val error = connection.coroutineContext.job.getCancellationException().cause assertTrue(error is RSocketError.Setup.Rejected) assertEquals(errorMessage, error.message) diff --git a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/internal/RSocketRequesterTest.kt b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/internal/RSocketRequesterTest.kt index e51c2d55..bd2b7499 100644 --- a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/internal/RSocketRequesterTest.kt +++ b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/internal/RSocketRequesterTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2023 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. @@ -254,6 +254,7 @@ class RSocketRequesterTest : TestWithConnection(), TestWithLeakCheck { connection.sendToReceiver(ErrorFrame(0, RSocketError.Setup.Rejected(errorMessage))) delay(100) assertFalse(requester.isActive) + @OptIn(InternalCoroutinesApi::class) val error = requester.coroutineContext.job.getCancellationException().cause assertTrue(error is RSocketError.Setup.Rejected) assertEquals(errorMessage, error.message) diff --git a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/keepalive/KeepAliveTest.kt b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/keepalive/KeepAliveTest.kt index e60d1631..312541d3 100644 --- a/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/keepalive/KeepAliveTest.kt +++ b/rsocket-core/src/commonTest/kotlin/io/rsocket/kotlin/keepalive/KeepAliveTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2023 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. @@ -102,6 +102,7 @@ class KeepAliveTest : TestWithConnection(), TestWithLeakCheck { connection.test { while (rSocket.isActive) kotlin.runCatching { awaitItem() } } + @OptIn(InternalCoroutinesApi::class) assertTrue(rSocket.coroutineContext.job.getCancellationException().cause is RSocketError.ConnectionError) } diff --git a/rsocket-internal-io/build.gradle.kts b/rsocket-internal-io/build.gradle.kts index c4a97454..a978c9b7 100644 --- a/rsocket-internal-io/build.gradle.kts +++ b/rsocket-internal-io/build.gradle.kts @@ -14,20 +14,23 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { - id("rsocketbuild.template.library") - id("rsocketbuild.target.all") + id("rsocketbuild.multiplatform-library") } +description = "rsocket-kotlin internal IO support" + kotlin { + jvmTarget() + jsTarget() + nativeTargets() + sourceSets { - commonMain { - dependencies { - api(libs.kotlinx.coroutines.core) - api(libs.ktor.io) - } + commonMain.dependencies { + api(libs.kotlinx.coroutines.core) + api(libs.ktor.io) } } } - -description = "rsocket-kotlin internal IO support" diff --git a/rsocket-ktor/build.gradle.kts b/rsocket-ktor/build.gradle.kts index c50c859c..b79629dc 100644 --- a/rsocket-ktor/build.gradle.kts +++ b/rsocket-ktor/build.gradle.kts @@ -14,21 +14,24 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { - id("rsocketbuild.template.library") - id("rsocketbuild.target.all") + id("rsocketbuild.multiplatform-library") } +description = "rsocket-kotlin ktor integration" + kotlin { + jvmTarget() + jsTarget() + nativeTargets() + sourceSets { - commonMain { - dependencies { - api(projects.rsocketCore) - api(projects.rsocketTransportKtor.rsocketTransportKtorWebsocket) - //TODO ContentNegotiation will be here later - } + commonMain.dependencies { + api(projects.rsocketCore) + api(projects.rsocketTransportKtor.rsocketTransportKtorWebsocket) + //TODO ContentNegotiation will be here later } } } - -description = "RSocket ktor integration" diff --git a/rsocket-ktor/rsocket-ktor-client/build.gradle.kts b/rsocket-ktor/rsocket-ktor-client/build.gradle.kts index 2ac2c96e..df4db279 100644 --- a/rsocket-ktor/rsocket-ktor-client/build.gradle.kts +++ b/rsocket-ktor/rsocket-ktor-client/build.gradle.kts @@ -14,20 +14,23 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { - id("rsocketbuild.template.library") - id("rsocketbuild.target.all") + id("rsocketbuild.multiplatform-library") } +description = "rsocket-kotlin ktor client plugin" + kotlin { + jvmTarget() + jsTarget() + nativeTargets() + sourceSets { - commonMain { - dependencies { - api(projects.rsocketKtor) - api(libs.ktor.client.websockets) - } + commonMain.dependencies { + api(projects.rsocketKtor) + api(libs.ktor.client.websockets) } } } - -description = "RSocket ktor client plugin" diff --git a/rsocket-ktor/rsocket-ktor-server/build.gradle.kts b/rsocket-ktor/rsocket-ktor-server/build.gradle.kts index ae312909..e1ebecf3 100644 --- a/rsocket-ktor/rsocket-ktor-server/build.gradle.kts +++ b/rsocket-ktor/rsocket-ktor-server/build.gradle.kts @@ -14,29 +14,28 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { - id("rsocketbuild.template.library") - id("rsocketbuild.target.jvm") - id("rsocketbuild.target.native.nix") + id("rsocketbuild.multiplatform-library") } +description = "rsocket-kotlin ktor server plugin" + kotlin { + jvmTarget() + nixTargets() + sourceSets { - commonMain { - dependencies { - api(projects.rsocketKtor) - api(libs.ktor.server.websockets) - } + commonMain.dependencies { + api(projects.rsocketKtor) + api(libs.ktor.server.websockets) } - commonTest { - dependencies { - implementation(projects.rsocketKtor.rsocketKtorClient) - implementation(projects.rsocketTransportTests) //port provider - implementation(libs.ktor.client.cio) - implementation(libs.ktor.server.cio) - } + commonTest.dependencies { + implementation(projects.rsocketKtor.rsocketKtorClient) + implementation(projects.rsocketTransportTests) //port provider + implementation(libs.ktor.client.cio) + implementation(libs.ktor.server.cio) } } } - -description = "RSocket ktor server plugin" diff --git a/rsocket-test/build.gradle.kts b/rsocket-test/build.gradle.kts index e4b7ca77..1357cedb 100644 --- a/rsocket-test/build.gradle.kts +++ b/rsocket-test/build.gradle.kts @@ -15,39 +15,48 @@ */ import org.jetbrains.kotlin.gradle.* +import rsocketbuild.* plugins { - id("rsocketbuild.template.test") - id("rsocketbuild.target.all") + id("rsocketbuild.multiplatform-base") id("kotlinx-atomicfu") } @OptIn(ExperimentalKotlinGradlePluginApi::class) kotlin { + jvmTarget() + jsTarget() + nativeTargets() + compilerOptions { freeCompilerArgs.add("-Xexpect-actual-classes") + optIn.addAll( + OptIns.ExperimentalStdlibApi, + OptIns.ExperimentalCoroutinesApi, + OptIns.DelicateCoroutinesApi, + + OptIns.RSocketLoggingApi, + ) } sourceSets { - commonMain { - dependencies { - api(kotlin("test")) - api(projects.rsocketCore) - implementation(projects.rsocketInternalIo) - - api(libs.kotlinx.coroutines.test) - api(libs.turbine) - } + commonMain.dependencies { + implementation(projects.rsocketInternalIo) + api(projects.rsocketCore) + + api(libs.kotlinx.coroutines.test) + api(libs.turbine) + } + + // expose kotlin-test + commonMain.dependencies { + api(kotlin("test")) } - jvmMain { - dependencies { - api(kotlin("test-junit")) - } + jvmMain.dependencies { + api(kotlin("test-junit")) } - jsMain { - dependencies { - api(kotlin("test-js")) - } + jsMain.dependencies { + api(kotlin("test-js")) } } } diff --git a/rsocket-transport-ktor/build.gradle.kts b/rsocket-transport-ktor/build.gradle.kts index dd3b3e35..0fd2e007 100644 --- a/rsocket-transport-ktor/build.gradle.kts +++ b/rsocket-transport-ktor/build.gradle.kts @@ -14,19 +14,22 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { - id("rsocketbuild.template.transport") - id("rsocketbuild.target.all") + id("rsocketbuild.multiplatform-library") } +description = "rsocket-kotlin ktor transport utilities" + kotlin { + jvmTarget() + jsTarget() + nativeTargets() + sourceSets { - commonMain { - dependencies { - api(projects.rsocketCore) - } + commonMain.dependencies { + api(projects.rsocketCore) } } } - -description = "RSocket ktor transport utilities" diff --git a/rsocket-transport-ktor/rsocket-transport-ktor-tcp/build.gradle.kts b/rsocket-transport-ktor/rsocket-transport-ktor-tcp/build.gradle.kts index 94b950cb..8b6077b6 100644 --- a/rsocket-transport-ktor/rsocket-transport-ktor-tcp/build.gradle.kts +++ b/rsocket-transport-ktor/rsocket-transport-ktor-tcp/build.gradle.kts @@ -14,23 +14,27 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { - id("rsocketbuild.template.transport") - id("rsocketbuild.target.jvm") - id("rsocketbuild.target.native.nix") + id("rsocketbuild.multiplatform-library") } +description = "rsocket-kotlin ktor TCP client/server transport implementation" + kotlin { + jvmTarget() + nixTargets() + sourceSets { - commonMain { - dependencies { - implementation(projects.rsocketInternalIo) + commonMain.dependencies { + implementation(projects.rsocketInternalIo) - api(projects.rsocketTransportKtor) - api(libs.ktor.network) - } + api(projects.rsocketTransportKtor) + api(libs.ktor.network) + } + commonTest.dependencies { + implementation(projects.rsocketTransportTests) } } } - -description = "RSocket ktor TCP client/server transport implementation" diff --git a/rsocket-transport-ktor/rsocket-transport-ktor-websocket-client/build.gradle.kts b/rsocket-transport-ktor/rsocket-transport-ktor-websocket-client/build.gradle.kts index 4a005472..7c0dd003 100644 --- a/rsocket-transport-ktor/rsocket-transport-ktor-websocket-client/build.gradle.kts +++ b/rsocket-transport-ktor/rsocket-transport-ktor-websocket-client/build.gradle.kts @@ -14,21 +14,24 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { - id("rsocketbuild.template.transport") - id("rsocketbuild.target.all") + id("rsocketbuild.multiplatform-library") } +description = "rsocket-kotlin ktor WebSocket client transport implementation" + kotlin { + jvmTarget() + jsTarget() + nativeTargets() + sourceSets { - commonMain { - dependencies { - api(projects.rsocketTransportKtor.rsocketTransportKtorWebsocket) - api(libs.ktor.client.core) - api(libs.ktor.client.websockets) - } + commonMain.dependencies { + api(projects.rsocketTransportKtor.rsocketTransportKtorWebsocket) + api(libs.ktor.client.core) + api(libs.ktor.client.websockets) } } } - -description = "RSocket ktor WebSocket client transport implementation" diff --git a/rsocket-transport-ktor/rsocket-transport-ktor-websocket-server/build.gradle.kts b/rsocket-transport-ktor/rsocket-transport-ktor-websocket-server/build.gradle.kts index cb83aa31..322a990e 100644 --- a/rsocket-transport-ktor/rsocket-transport-ktor-websocket-server/build.gradle.kts +++ b/rsocket-transport-ktor/rsocket-transport-ktor-websocket-server/build.gradle.kts @@ -14,38 +14,35 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { - id("rsocketbuild.template.transport") - id("rsocketbuild.target.jvm") - id("rsocketbuild.target.native.nix") + id("rsocketbuild.multiplatform-library") } +description = "rsocket-kotlin ktor WebSocket server transport implementation" + kotlin { + jvmTarget() + nixTargets() + sourceSets { - commonMain { - dependencies { - api(projects.rsocketTransportKtor.rsocketTransportKtorWebsocket) - api(libs.ktor.server.host.common) - api(libs.ktor.server.websockets) - } + commonMain.dependencies { + api(projects.rsocketTransportKtor.rsocketTransportKtorWebsocket) + api(libs.ktor.server.host.common) + api(libs.ktor.server.websockets) } - commonTest { - dependencies { - implementation(projects.rsocketTransportKtor.rsocketTransportKtorWebsocketClient) - implementation(libs.ktor.client.cio) - implementation(libs.ktor.server.cio) - } + commonTest.dependencies { + implementation(projects.rsocketTransportTests) + implementation(projects.rsocketTransportKtor.rsocketTransportKtorWebsocketClient) + implementation(libs.ktor.client.cio) + implementation(libs.ktor.server.cio) } + jvmTest.dependencies { + implementation(libs.ktor.client.okhttp) - jvmTest { - dependencies { - implementation(libs.ktor.client.okhttp) - - implementation(libs.ktor.server.netty) - implementation(libs.ktor.server.jetty) - } + implementation(libs.ktor.server.netty) + implementation(libs.ktor.server.jetty) } } } - -description = "RSocket ktor WebSocket server transport implementation" diff --git a/rsocket-transport-ktor/rsocket-transport-ktor-websocket/build.gradle.kts b/rsocket-transport-ktor/rsocket-transport-ktor-websocket/build.gradle.kts index 3da71397..2094900d 100644 --- a/rsocket-transport-ktor/rsocket-transport-ktor-websocket/build.gradle.kts +++ b/rsocket-transport-ktor/rsocket-transport-ktor-websocket/build.gradle.kts @@ -14,20 +14,23 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { - id("rsocketbuild.template.transport") - id("rsocketbuild.target.all") + id("rsocketbuild.multiplatform-library") } +description = "rsocket-kotlin ktor WebSocket transport utilities" + kotlin { + jvmTarget() + jsTarget() + nativeTargets() + sourceSets { - commonMain { - dependencies { - api(projects.rsocketTransportKtor) - api(libs.ktor.websockets) - } + commonMain.dependencies { + api(projects.rsocketTransportKtor) + api(libs.ktor.websockets) } } } - -description = "RSocket ktor WebSocket transport utilities" diff --git a/rsocket-transport-local/build.gradle.kts b/rsocket-transport-local/build.gradle.kts index 3c18774c..edb2dc3d 100644 --- a/rsocket-transport-local/build.gradle.kts +++ b/rsocket-transport-local/build.gradle.kts @@ -14,21 +14,26 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { - id("rsocketbuild.template.transport") - id("rsocketbuild.target.all") + id("rsocketbuild.multiplatform-library") } +description = "rsocket-kotlin Local transport implementation" + kotlin { - sourceSets { - commonMain { - dependencies { - implementation(projects.rsocketInternalIo) + jvmTarget() + jsTarget() + nativeTargets() - api(projects.rsocketCore) - } + sourceSets { + commonMain.dependencies { + implementation(projects.rsocketInternalIo) + api(projects.rsocketCore) + } + commonTest.dependencies { + implementation(projects.rsocketTransportTests) } } } - -description = "RSocket Local transport implementation" diff --git a/rsocket-transport-nodejs-tcp/build.gradle.kts b/rsocket-transport-nodejs-tcp/build.gradle.kts index 2c30c4ac..c048c5d6 100644 --- a/rsocket-transport-nodejs-tcp/build.gradle.kts +++ b/rsocket-transport-nodejs-tcp/build.gradle.kts @@ -14,21 +14,24 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { - id("rsocketbuild.template.transport") - id("rsocketbuild.target.js.node") + id("rsocketbuild.multiplatform-library") } +description = "rsocket-kotlin NodeJS TCP client/server transport implementation" + kotlin { - sourceSets { - jsMain { - dependencies { - implementation(projects.rsocketInternalIo) + jsTarget(supportsBrowser = false) - api(projects.rsocketCore) - } + sourceSets { + jsMain.dependencies { + implementation(projects.rsocketInternalIo) + api(projects.rsocketCore) + } + jsTest.dependencies { + implementation(projects.rsocketTransportTests) } } } - -description = "RSocket NodeJS TCP client/server transport implementation" diff --git a/rsocket-transport-tests/build.gradle.kts b/rsocket-transport-tests/build.gradle.kts index 970bebc4..592e51ee 100644 --- a/rsocket-transport-tests/build.gradle.kts +++ b/rsocket-transport-tests/build.gradle.kts @@ -14,78 +14,29 @@ * limitations under the License. */ +import org.jetbrains.kotlin.gradle.* +import rsocketbuild.* + plugins { - id("rsocketbuild.template.test") - id("rsocketbuild.target.all") + id("rsocketbuild.multiplatform-base") id("kotlinx-atomicfu") } +@OptIn(ExperimentalKotlinGradlePluginApi::class) kotlin { + jvmTarget() + jsTarget() + nativeTargets() + + compilerOptions { + optIn.addAll( + OptIns.ExperimentalStreamsApi, + ) + } + sourceSets { - commonMain { - dependencies { - api(projects.rsocketTest) - } - } - jvmTest { - dependencies { - implementation(projects.rsocketTransportKtor.rsocketTransportKtorTcp) - implementation(projects.rsocketTransportKtor.rsocketTransportKtorWebsocketServer) - implementation(libs.ktor.server.cio) - } + commonMain.dependencies { + api(projects.rsocketTest) } } } - -//open class StartTransportTestServer : DefaultTask() { -// @Internal -// var server: Closeable? = null -// private set -// -// @Internal -// lateinit var classpath: FileCollection -// -// @TaskAction -// fun exec() { -// try { -// println("[TransportTestServer] start") -// server = URLClassLoader( -// classpath.map { it.toURI().toURL() }.toTypedArray(), -// ClassLoader.getSystemClassLoader() -// ) -// .loadClass("io.rsocket.kotlin.transport.tests.server.AppKt") -// .getMethod("start") -// .invoke(null) as Closeable -// println("[TransportTestServer] started") -// } catch (cause: Throwable) { -// println("[TransportTestServer] failed to start: ${cause.message}") -// cause.printStackTrace() -// } -// } -//} -// -//val startTransportTestServer by tasks.registering(StartTransportTestServer::class) { -// dependsOn(tasks["jvmTest"]) //TODO? -// classpath = (kotlin.targets["jvm"].compilations["test"] as KotlinJvmCompilation).runtimeDependencyFiles -//} -// -//rootProject.allprojects { -// if (name == "rsocket-transport-ktor-websocket-client") { -// val names = setOf( -// "jsLegacyNodeTest", -// "jsIrNodeTest", -// "jsLegacyBrowserTest", -// "jsIrBrowserTest", -// ) -// tasks.all { -// if (name in names) dependsOn(startTransportTestServer) -// } -// } -//} -// -//gradle.buildFinished { -// startTransportTestServer.get().server?.run { -// close() -// println("[TransportTestServer] stopped") -// } -//} diff --git a/rsocket-transport-tests/src/jvmTest/kotlin/io/rsocket/kotlin/transport/tests/server/App.kt b/rsocket-transport-tests/src/jvmTest/kotlin/io/rsocket/kotlin/transport/tests/server/App.kt deleted file mode 100644 index f45f7edf..00000000 --- a/rsocket-transport-tests/src/jvmTest/kotlin/io/rsocket/kotlin/transport/tests/server/App.kt +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2015-2022 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.transport.tests.server - -import io.ktor.server.cio.* -import io.rsocket.kotlin.transport.ktor.tcp.* -import io.rsocket.kotlin.transport.ktor.websocket.server.* -import io.rsocket.kotlin.transport.tests.* -import kotlinx.coroutines.* -import java.io.* - -fun start(): Closeable { - val job = Job() - val scope = CoroutineScope(job) - - runBlocking { - TransportTest.SERVER.bindIn( - scope, - TcpServerTransport(port = PortProvider.testServerTcp), - TransportTest.ACCEPTOR - ).serverSocket.await() //await server start - } - - TransportTest.SERVER.bindIn( - scope, - WebSocketServerTransport(CIO, port = PortProvider.testServerWebSocket), - TransportTest.ACCEPTOR - ) - - Thread.sleep(1000) //await start - - return Closeable { - runBlocking { - job.cancelAndJoin() - } - } -}