From 2f4e1d034ac2945cf328832da272e2ce957a9ad1 Mon Sep 17 00:00:00 2001 From: Oleg Yukhnevich Date: Mon, 13 Nov 2023 01:39:50 +0200 Subject: [PATCH] Explicit targets and dependencies declarations --- .../rsocketbuild.multiplatform.gradle.kts | 49 +++++++++++- ...ocketbuild.multiplatform.native.gradle.kts | 33 -------- .../kotlin/rsocketbuild.target.all.gradle.kts | 21 ----- .../rsocketbuild.target.js.all.gradle.kts | 20 ----- .../rsocketbuild.target.js.browser.gradle.kts | 32 -------- .../rsocketbuild.target.js.node.gradle.kts | 31 ------- .../kotlin/rsocketbuild.target.jvm.gradle.kts | 42 ---------- .../rsocketbuild.target.native.all.gradle.kts | 23 ------ ...socketbuild.target.native.apple.gradle.kts | 38 --------- .../rsocketbuild.target.native.nix.gradle.kts | 23 ------ .../rsocketbuild.template.library.gradle.kts | 8 -- .../rsocketbuild.template.test.gradle.kts | 2 + ...rsocketbuild.template.transport.gradle.kts | 29 ------- .../kotlin/{ => rsocketbuild}/TestOptIn.kt | 2 + .../src/main/kotlin/rsocketbuild/targets.kt | 80 +++++++++++++++++++ rsocket-core/build.gradle.kts | 8 +- rsocket-internal-io/build.gradle.kts | 7 +- rsocket-ktor-client/build.gradle.kts | 7 +- rsocket-ktor-server/build.gradle.kts | 7 +- rsocket-test/build.gradle.kts | 7 +- rsocket-transport-ktor-tcp/build.gradle.kts | 14 +++- .../build.gradle.kts | 14 +++- .../build.gradle.kts | 10 ++- .../build.gradle.kts | 9 ++- rsocket-transport-local/build.gradle.kts | 14 +++- rsocket-transport-nodejs-tcp/build.gradle.kts | 12 ++- rsocket-transport-tests/build.gradle.kts | 67 ++-------------- .../kotlin/transport/tests/server/App.kt | 51 ------------ 28 files changed, 226 insertions(+), 434 deletions(-) delete mode 100644 build-logic/src/main/kotlin/rsocketbuild.multiplatform.native.gradle.kts delete mode 100644 build-logic/src/main/kotlin/rsocketbuild.target.all.gradle.kts delete mode 100644 build-logic/src/main/kotlin/rsocketbuild.target.js.all.gradle.kts delete mode 100644 build-logic/src/main/kotlin/rsocketbuild.target.js.browser.gradle.kts delete mode 100644 build-logic/src/main/kotlin/rsocketbuild.target.js.node.gradle.kts delete mode 100644 build-logic/src/main/kotlin/rsocketbuild.target.jvm.gradle.kts delete mode 100644 build-logic/src/main/kotlin/rsocketbuild.target.native.all.gradle.kts delete mode 100644 build-logic/src/main/kotlin/rsocketbuild.target.native.apple.gradle.kts delete mode 100644 build-logic/src/main/kotlin/rsocketbuild.target.native.nix.gradle.kts delete mode 100644 build-logic/src/main/kotlin/rsocketbuild.template.transport.gradle.kts rename build-logic/src/main/kotlin/{ => rsocketbuild}/TestOptIn.kt (98%) create mode 100644 build-logic/src/main/kotlin/rsocketbuild/targets.kt delete mode 100644 rsocket-transport-tests/src/jvmTest/kotlin/io/rsocket/kotlin/transport/tests/server/App.kt diff --git a/build-logic/src/main/kotlin/rsocketbuild.multiplatform.gradle.kts b/build-logic/src/main/kotlin/rsocketbuild.multiplatform.gradle.kts index dc1133b8..0d43b73b 100644 --- a/build-logic/src/main/kotlin/rsocketbuild.multiplatform.gradle.kts +++ b/build-logic/src/main/kotlin/rsocketbuild.multiplatform.gradle.kts @@ -14,13 +14,17 @@ * limitations under the License. */ +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 rsocketbuild.* + plugins { kotlin("multiplatform") } kotlin { - jvmToolchain(8) - targets.configureEach { compilations.configureEach { compilerOptions.configure { @@ -29,6 +33,47 @@ kotlin { } } + targets.withType().configureEach { + 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") + } + } + } + + // 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" + } + } + } + } + + targets.withType>().configureEach { + //setup tests running in RELEASE mode + binaries.test(listOf(NativeBuildType.RELEASE)) + testRuns.create("releaseTest") { + setExecutionSourceFrom(binaries.getTest(NativeBuildType.RELEASE)) + } + //don't even link tests if we can't run them (like, linux on macos, or mingw on linux/macos, etc) + testRuns.configureEach { + executionSource.binary.linkTaskProvider.get().enabled = (this as ExecutionTaskHolder<*>).executionTask.get().enabled + } + } + sourceSets.configureEach { languageSettings { progressiveMode = true 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 e6dae787..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.multiplatform.native.gradle.kts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2015-2023 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 e38bc5d7..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.target.all.gradle.kts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2015-2023 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 7a6ce514..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.target.js.all.gradle.kts +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2015-2023 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 eea1b0f4..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.target.js.browser.gradle.kts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2015-2023 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 975a1446..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.target.js.node.gradle.kts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2015-2023 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 22679210..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.target.jvm.gradle.kts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2015-2023 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 { - jvm { - listOf(11, 17, 20).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") - } - } - } -} diff --git a/build-logic/src/main/kotlin/rsocketbuild.target.native.all.gradle.kts b/build-logic/src/main/kotlin/rsocketbuild.target.native.all.gradle.kts deleted file mode 100644 index b47f5d35..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.target.native.all.gradle.kts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2015-2023 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.nix") -} - -kotlin { - mingwX64() -} diff --git a/build-logic/src/main/kotlin/rsocketbuild.target.native.apple.gradle.kts b/build-logic/src/main/kotlin/rsocketbuild.target.native.apple.gradle.kts deleted file mode 100644 index de67f8e7..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.target.native.apple.gradle.kts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2015-2023 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.native") -} - -kotlin { - macosX64() - macosArm64() - - iosArm64() - iosX64() - iosSimulatorArm64() - - tvosArm64() - tvosX64() - tvosSimulatorArm64() - - //TODO: after coroutines 1.7.0 add watchosDeviceArm64() - watchosArm32() - watchosArm64() - watchosX64() - watchosSimulatorArm64() -} 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 961fa6f7..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.target.native.nix.gradle.kts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2015-2023 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 index b492f9a6..c24075c3 100644 --- a/build-logic/src/main/kotlin/rsocketbuild.template.library.gradle.kts +++ b/build-logic/src/main/kotlin/rsocketbuild.template.library.gradle.kts @@ -21,12 +21,4 @@ plugins { 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 index da7f7be8..f3891162 100644 --- a/build-logic/src/main/kotlin/rsocketbuild.template.test.gradle.kts +++ b/build-logic/src/main/kotlin/rsocketbuild.template.test.gradle.kts @@ -14,6 +14,8 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { id("rsocketbuild.multiplatform") } 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 3d0c3265..00000000 --- a/build-logic/src/main/kotlin/rsocketbuild.template.transport.gradle.kts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2015-2023 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/TestOptIn.kt b/build-logic/src/main/kotlin/rsocketbuild/TestOptIn.kt similarity index 98% rename from build-logic/src/main/kotlin/TestOptIn.kt rename to build-logic/src/main/kotlin/rsocketbuild/TestOptIn.kt index 704ae4f1..bd4280d1 100644 --- a/build-logic/src/main/kotlin/TestOptIn.kt +++ b/build-logic/src/main/kotlin/rsocketbuild/TestOptIn.kt @@ -14,6 +14,8 @@ * limitations under the License. */ +package rsocketbuild + import org.jetbrains.kotlin.gradle.plugin.* //TODO may be remove part of annotations 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..ac671b80 --- /dev/null +++ b/build-logic/src/main/kotlin/rsocketbuild/targets.kt @@ -0,0 +1,80 @@ +/* + * Copyright 2015-2023 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() + + tvosArm64() + tvosX64() + tvosSimulatorArm64() + + // TODO: add watchosDeviceArm64() when it will be supported in ktor + // https://youtrack.jetbrains.com/issue/KTOR-6368 + watchosArm32() + watchosArm64() + watchosX64() + watchosSimulatorArm64() +} + +fun KotlinMultiplatformExtension.nixTargets() { + appleTargets() + linuxX64() +} + +fun KotlinMultiplatformExtension.nativeTargets() { + nixTargets() + mingwX64() +} + +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, 20), +) { + 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/rsocket-core/build.gradle.kts b/rsocket-core/build.gradle.kts index e7657401..e6413bf2 100644 --- a/rsocket-core/build.gradle.kts +++ b/rsocket-core/build.gradle.kts @@ -14,13 +14,18 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { id("rsocketbuild.template.library") - id("rsocketbuild.target.all") id("kotlinx-atomicfu") } kotlin { + jvmTarget() + jsTarget() + nativeTargets() + sourceSets { commonMain { dependencies { @@ -32,6 +37,7 @@ kotlin { } commonTest { dependencies { + implementation(projects.rsocketTest) implementation(projects.rsocketTransportLocal) } } diff --git a/rsocket-internal-io/build.gradle.kts b/rsocket-internal-io/build.gradle.kts index 6ab2bfdc..2d14bd74 100644 --- a/rsocket-internal-io/build.gradle.kts +++ b/rsocket-internal-io/build.gradle.kts @@ -14,12 +14,17 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { id("rsocketbuild.template.library") - id("rsocketbuild.target.all") } kotlin { + jvmTarget() + jsTarget() + nativeTargets() + sourceSets { commonMain { dependencies { diff --git a/rsocket-ktor-client/build.gradle.kts b/rsocket-ktor-client/build.gradle.kts index 469c1d6d..85374b91 100644 --- a/rsocket-ktor-client/build.gradle.kts +++ b/rsocket-ktor-client/build.gradle.kts @@ -14,12 +14,17 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { id("rsocketbuild.template.library") - id("rsocketbuild.target.all") } kotlin { + jvmTarget() + jsTarget() + nativeTargets() + sourceSets { commonMain { dependencies { diff --git a/rsocket-ktor-server/build.gradle.kts b/rsocket-ktor-server/build.gradle.kts index eabc3866..ade0f2ca 100644 --- a/rsocket-ktor-server/build.gradle.kts +++ b/rsocket-ktor-server/build.gradle.kts @@ -14,13 +14,16 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { id("rsocketbuild.template.library") - id("rsocketbuild.target.jvm") - id("rsocketbuild.target.native.nix") } kotlin { + jvmTarget() + nixTargets() + sourceSets { commonMain { dependencies { diff --git a/rsocket-test/build.gradle.kts b/rsocket-test/build.gradle.kts index 8fcd8e98..1e9dd30d 100644 --- a/rsocket-test/build.gradle.kts +++ b/rsocket-test/build.gradle.kts @@ -14,13 +14,18 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { id("rsocketbuild.template.test") - id("rsocketbuild.target.all") id("kotlinx-atomicfu") } kotlin { + jvmTarget() + jsTarget() + nativeTargets() + sourceSets { commonMain { dependencies { diff --git a/rsocket-transport-ktor-tcp/build.gradle.kts b/rsocket-transport-ktor-tcp/build.gradle.kts index e45ef79d..2c330449 100644 --- a/rsocket-transport-ktor-tcp/build.gradle.kts +++ b/rsocket-transport-ktor-tcp/build.gradle.kts @@ -14,13 +14,16 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { - id("rsocketbuild.template.transport") - id("rsocketbuild.target.jvm") - id("rsocketbuild.target.native.nix") + id("rsocketbuild.template.library") } kotlin { + jvmTarget() + nixTargets() + sourceSets { commonMain { dependencies { @@ -30,6 +33,11 @@ kotlin { api(libs.ktor.network) } } + commonTest { + dependencies { + implementation(projects.rsocketTransportTests) + } + } } } diff --git a/rsocket-transport-ktor-websocket-client/build.gradle.kts b/rsocket-transport-ktor-websocket-client/build.gradle.kts index 52042ad5..abac3658 100644 --- a/rsocket-transport-ktor-websocket-client/build.gradle.kts +++ b/rsocket-transport-ktor-websocket-client/build.gradle.kts @@ -14,12 +14,17 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { - id("rsocketbuild.template.transport") - id("rsocketbuild.target.all") + id("rsocketbuild.template.library") } kotlin { + jvmTarget() + jsTarget() + nativeTargets() + sourceSets { commonMain { dependencies { @@ -28,6 +33,11 @@ kotlin { api(libs.ktor.client.websockets) } } + commonTest { + dependencies { + implementation(projects.rsocketTransportTests) + } + } } } diff --git a/rsocket-transport-ktor-websocket-server/build.gradle.kts b/rsocket-transport-ktor-websocket-server/build.gradle.kts index b8f69bb8..fcbfb747 100644 --- a/rsocket-transport-ktor-websocket-server/build.gradle.kts +++ b/rsocket-transport-ktor-websocket-server/build.gradle.kts @@ -14,13 +14,16 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { - id("rsocketbuild.template.transport") - id("rsocketbuild.target.jvm") - id("rsocketbuild.target.native.nix") + id("rsocketbuild.template.library") } kotlin { + jvmTarget() + nixTargets() + sourceSets { commonMain { dependencies { @@ -31,6 +34,7 @@ kotlin { } commonTest { dependencies { + implementation(projects.rsocketTransportTests) implementation(projects.rsocketTransportKtorWebsocketClient) implementation(libs.ktor.client.cio) implementation(libs.ktor.server.cio) diff --git a/rsocket-transport-ktor-websocket-shared/build.gradle.kts b/rsocket-transport-ktor-websocket-shared/build.gradle.kts index bfc6e181..e3c060b5 100644 --- a/rsocket-transport-ktor-websocket-shared/build.gradle.kts +++ b/rsocket-transport-ktor-websocket-shared/build.gradle.kts @@ -14,12 +14,17 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { - id("rsocketbuild.template.transport") - id("rsocketbuild.target.all") + id("rsocketbuild.template.library") } kotlin { + jvmTarget() + jsTarget() + nativeTargets() + sourceSets { commonMain { dependencies { diff --git a/rsocket-transport-local/build.gradle.kts b/rsocket-transport-local/build.gradle.kts index 39d8cf58..142feff2 100644 --- a/rsocket-transport-local/build.gradle.kts +++ b/rsocket-transport-local/build.gradle.kts @@ -14,12 +14,17 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { - id("rsocketbuild.template.transport") - id("rsocketbuild.target.all") + id("rsocketbuild.template.library") } kotlin { + jvmTarget() + jsTarget() + nativeTargets() + sourceSets { commonMain { dependencies { @@ -28,6 +33,11 @@ kotlin { api(projects.rsocketCore) } } + commonTest { + dependencies { + implementation(projects.rsocketTransportTests) + } + } } } diff --git a/rsocket-transport-nodejs-tcp/build.gradle.kts b/rsocket-transport-nodejs-tcp/build.gradle.kts index e5d3d3a1..fe91333c 100644 --- a/rsocket-transport-nodejs-tcp/build.gradle.kts +++ b/rsocket-transport-nodejs-tcp/build.gradle.kts @@ -14,12 +14,15 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { - id("rsocketbuild.template.transport") - id("rsocketbuild.target.js.node") + id("rsocketbuild.template.library") } kotlin { + jsTarget(supportsBrowser = false) + sourceSets { jsMain { dependencies { @@ -28,6 +31,11 @@ kotlin { api(projects.rsocketCore) } } + commonTest { + dependencies { + implementation(projects.rsocketTransportTests) + } + } } } diff --git a/rsocket-transport-tests/build.gradle.kts b/rsocket-transport-tests/build.gradle.kts index 3eb0a85c..badc4c39 100644 --- a/rsocket-transport-tests/build.gradle.kts +++ b/rsocket-transport-tests/build.gradle.kts @@ -14,78 +14,23 @@ * limitations under the License. */ +import rsocketbuild.* + plugins { id("rsocketbuild.template.test") - id("rsocketbuild.target.all") id("kotlinx-atomicfu") } kotlin { + jvmTarget() + jsTarget() + nativeTargets() + sourceSets { commonMain { dependencies { api(projects.rsocketTest) } } - jvmTest { - dependencies { - implementation(projects.rsocketTransportKtorTcp) - implementation(projects.rsocketTransportKtorWebsocketServer) - implementation(libs.ktor.server.cio) - } - } } } - -//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() - } - } -}