Skip to content

Commit

Permalink
restructure transport modules
Browse files Browse the repository at this point in the history
* rename ktor-websocket to ktor-websocket-internal and make it an implementation dependency (not exposed)
* move all transports under `rsocket-transports` folder
* drop empty modules
* implement small DSL for including projects
  • Loading branch information
whyoleg committed Mar 2, 2024
1 parent cd050d5 commit ee5446e
Show file tree
Hide file tree
Showing 52 changed files with 96 additions and 139 deletions.
47 changes: 47 additions & 0 deletions build-settings/src/main/kotlin/rsocketsettings/ProjectsScope.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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 rsocketsettings

import org.gradle.api.initialization.*

fun Settings.projects(block: ProjectsScope.() -> Unit) {
ProjectsScope(settings, emptyList(), emptyList()).apply(block)
}

class ProjectsScope(
private val settings: Settings,
private val pathParts: List<String>,
private val prefixParts: List<String>,
) {

fun module(name: String) {
val moduleName = (prefixParts + name).joinToString("-")
val modulePath = (pathParts + name).joinToString("/")

settings.include(moduleName)
settings.project(":$moduleName").projectDir = settings.rootDir.resolve(modulePath)
}

fun module(name: String, prefix: String = name, nested: ProjectsScope.() -> Unit = {}) {
module(name)
folder(name, prefix, nested)
}

fun folder(name: String, prefix: String = name, block: ProjectsScope.() -> Unit) {
ProjectsScope(settings, pathParts + name, prefixParts + prefix).apply(block)
}
}
Empty file removed rsocket-ktor/api/rsocket-ktor.api
Empty file.
37 changes: 0 additions & 37 deletions rsocket-ktor/build.gradle.kts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ kotlin {

sourceSets {
commonMain.dependencies {
api(projects.rsocketKtor)
implementation(projects.rsocketTransportKtorWebsocketInternal)
api(projects.rsocketCore)
api(libs.ktor.client.websockets)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import io.ktor.client.request.*
import io.ktor.http.*
import io.rsocket.kotlin.*
import io.rsocket.kotlin.transport.*
import io.rsocket.kotlin.transport.ktor.websocket.*
import io.rsocket.kotlin.transport.ktor.websocket.internal.*
import kotlin.coroutines.*

public suspend fun HttpClient.rSocket(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ kotlin {

sourceSets {
commonMain.dependencies {
api(projects.rsocketKtor)
implementation(projects.rsocketTransportKtorWebsocketInternal)
api(projects.rsocketCore)
api(libs.ktor.server.websockets)
}
commonTest.dependencies {
implementation(projects.rsocketKtor.rsocketKtorClient)
implementation(projects.rsocketKtorClient)
implementation(projects.rsocketTransportTests) //port provider
implementation(libs.ktor.client.cio)
implementation(libs.ktor.server.cio)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import io.ktor.server.routing.*
import io.ktor.server.websocket.*
import io.rsocket.kotlin.*
import io.rsocket.kotlin.transport.*
import io.rsocket.kotlin.transport.ktor.websocket.*
import io.rsocket.kotlin.transport.ktor.websocket.internal.*
import kotlinx.coroutines.*

public fun Route.rSocket(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2022 the original author or authors.
* Copyright 2015-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down

This file was deleted.

Empty file.
35 changes: 0 additions & 35 deletions rsocket-transport-ktor/build.gradle.kts

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ kotlin {
sourceSets {
commonMain.dependencies {
implementation(projects.rsocketInternalIo)

api(projects.rsocketTransportKtor)
api(projects.rsocketCore)
api(libs.ktor.network)
}
commonTest.dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2022 the original author or authors.
* Copyright 2015-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2022 the original author or authors.
* Copyright 2015-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ kotlin {

sourceSets {
commonMain.dependencies {
api(projects.rsocketTransportKtor.rsocketTransportKtorWebsocket)
implementation(projects.rsocketTransportKtorWebsocketInternal)
api(projects.rsocketCore)
api(libs.ktor.client.core)
api(libs.ktor.client.websockets)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import io.ktor.client.request.*
import io.ktor.http.*
import io.rsocket.kotlin.*
import io.rsocket.kotlin.transport.*
import io.rsocket.kotlin.transport.ktor.websocket.*
import io.rsocket.kotlin.transport.ktor.websocket.internal.*
import kotlinx.coroutines.*
import kotlin.coroutines.*

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public final class io/rsocket/kotlin/transport/ktor/websocket/WebSocketConnection : io/rsocket/kotlin/Connection, kotlinx/coroutines/CoroutineScope {
public final class io/rsocket/kotlin/transport/ktor/websocket/internal/WebSocketConnection : io/rsocket/kotlin/Connection, kotlinx/coroutines/CoroutineScope {
public fun <init> (Lio/ktor/websocket/WebSocketSession;)V
public fun getCoroutineContext ()Lkotlin/coroutines/CoroutineContext;
public fun receive (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ kotlin {

sourceSets {
commonMain.dependencies {
api(projects.rsocketTransportKtor)
api(projects.rsocketCore)
api(libs.ktor.websockets)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.rsocket.kotlin.transport.ktor.websocket
package io.rsocket.kotlin.transport.ktor.websocket.internal

import io.ktor.utils.io.core.*
import io.ktor.websocket.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ kotlin {

sourceSets {
commonMain.dependencies {
api(projects.rsocketTransportKtor.rsocketTransportKtorWebsocket)
implementation(projects.rsocketTransportKtorWebsocketInternal)
api(projects.rsocketCore)
api(libs.ktor.server.host.common)
api(libs.ktor.server.websockets)
}
commonTest.dependencies {
implementation(projects.rsocketTransportTests)
implementation(projects.rsocketTransportKtor.rsocketTransportKtorWebsocketClient)
implementation(projects.rsocketTransportKtorWebsocketClient)
implementation(libs.ktor.client.cio)
implementation(libs.ktor.server.cio)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import io.ktor.server.routing.*
import io.ktor.server.websocket.*
import io.rsocket.kotlin.*
import io.rsocket.kotlin.transport.*
import io.rsocket.kotlin.transport.ktor.websocket.*
import io.rsocket.kotlin.transport.ktor.websocket.internal.*

//TODO: will be reworked later with transport API rework

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2022 the original author or authors.
* Copyright 2015-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2022 the original author or authors.
* Copyright 2015-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2022 the original author or authors.
* Copyright 2015-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2022 the original author or authors.
* Copyright 2015-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
43 changes: 22 additions & 21 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

import rsocketsettings.*

pluginManagement {
includeBuild("build-logic")
includeBuild("build-settings")
Expand All @@ -25,30 +27,29 @@ plugins {

rootProject.name = "rsocket-kotlin"

//include("benchmarks")
projects {
module("rsocket-internal-io")
module("rsocket-core")

include("rsocket-internal-io")
module("rsocket-test")
module("rsocket-transport-tests")

include("rsocket-core")
include("rsocket-test")
// transports
folder("rsocket-transports", "rsocket-transport") {
module("local")

include("rsocket-transport-tests")
include("rsocket-transport-local")
module("ktor-tcp")

//ktor transport modules
include(
"rsocket-transport-ktor",
"rsocket-transport-ktor:rsocket-transport-ktor-tcp",
"rsocket-transport-ktor:rsocket-transport-ktor-websocket",
"rsocket-transport-ktor:rsocket-transport-ktor-websocket-client",
"rsocket-transport-ktor:rsocket-transport-ktor-websocket-server",
)
module("ktor-websocket-client")
module("ktor-websocket-server")
module("ktor-websocket-internal")

include("rsocket-transport-nodejs-tcp")
module("nodejs-tcp")
}

//deep ktor integration module
include(
"rsocket-ktor",
"rsocket-ktor:rsocket-ktor-client",
"rsocket-ktor:rsocket-ktor-server",
)
// ktor integration module
folder("rsocket-ktor") {
module("client")
module("server")
}
}

0 comments on commit ee5446e

Please sign in to comment.