Skip to content

Commit 1e176a1

Browse files
Update samples (#365)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent 34fa8ef commit 1e176a1

File tree

44 files changed

+100
-130
lines changed

Some content is hidden

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

44 files changed

+100
-130
lines changed

samples/grpc-app/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
plugins {
66
kotlin("jvm") version "2.1.10"
77
kotlin("plugin.serialization") version "2.1.10"
8-
id("org.jetbrains.kotlinx.rpc.plugin") version "0.6.0"
8+
id("org.jetbrains.kotlinx.rpc.plugin") version "0.7.0"
99
id("com.google.protobuf") version "0.9.5"
1010
}
1111

@@ -22,9 +22,9 @@ kotlin {
2222
}
2323

2424
dependencies {
25-
implementation("org.jetbrains.kotlinx:kotlinx-rpc-grpc-core:0.5.1-grpc-39")
25+
implementation("org.jetbrains.kotlinx:kotlinx-rpc-grpc-core:0.7.0-grpc-56")
2626
implementation("ch.qos.logback:logback-classic:1.5.18")
27-
implementation("io.grpc:grpc-netty:1.71.0")
27+
implementation("io.grpc:grpc-netty:1.73.0")
2828
}
2929

3030
rpc {

samples/grpc-app/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

samples/ktor-all-platforms-app/composeApp/build.gradle.kts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
66
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
77
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
8-
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
98
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
109

1110
plugins {
@@ -17,9 +16,9 @@ plugins {
1716
}
1817

1918
kotlin {
20-
@OptIn(ExperimentalWasmDsl::class)
19+
@OptIn(org.jetbrains.kotlin.gradle.ExperimentalWasmDsl::class)
2120
wasmJs {
22-
moduleName = "composeApp"
21+
outputModuleName = "composeApp"
2322
browser {
2423
val projectDirPath = project.projectDir.path
2524
commonWebpackConfig {

samples/ktor-all-platforms-app/composeApp/src/commonMain/kotlin/App.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import kotlinx.rpc.krpc.ktor.client.installKrpc
1818
import kotlinx.rpc.krpc.ktor.client.rpc
1919
import kotlinx.rpc.krpc.ktor.client.rpcConfig
2020
import kotlinx.rpc.krpc.serialization.json.json
21-
import kotlinx.rpc.krpc.streamScoped
2221
import kotlinx.rpc.withService
2322
import ktor_all_platforms_app.composeapp.generated.resources.Res
2423
import ktor_all_platforms_app.composeapp.generated.resources.compose_multiplatform

samples/ktor-all-platforms-app/gradle/libs.versions.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
[versions]
2-
kotlin = "2.1.21"
2+
kotlin = "2.2.0"
33

4-
agp = "8.9.1"
5-
android-compileSdk = "35"
4+
agp = "8.11.0-alpha07"
5+
android-compileSdk = "36"
66
android-minSdk = "24"
7-
android-targetSdk = "35"
7+
android-targetSdk = "36"
88
androidx-activityCompose = "1.10.1"
9-
androidx-appcompat = "1.7.0"
9+
androidx-appcompat = "1.7.1"
1010
androidx-constraintlayout = "2.2.1"
1111
androidx-core-ktx = "1.16.0"
1212
androidx-espresso-core = "3.6.1"
1313
androidx-material = "1.12.0"
1414
androidx-test-junit = "1.2.1"
15-
compose = "1.7.8"
16-
compose-plugin = "1.8.0-SNAPSHOT+pull-5245"
15+
compose = "1.8.3"
16+
compose-plugin = "1.8.2"
1717
junit = "4.13.2"
18-
ktor = "3.1.2"
18+
ktor = "3.1.3"
1919
logback = "1.5.18"
2020
serialization = "1.8.1"
2121
coroutines = "1.10.2"
22-
kotlinx-rpc = "0.7.0"
22+
kotlinx-rpc = "0.8.0"
2323

2424
[libraries]
2525
# kotlin
Binary file not shown.

samples/ktor-all-platforms-app/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

samples/ktor-all-platforms-app/gradlew

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ case "$( uname )" in #(
114114
NONSTOP* ) nonstop=true ;;
115115
esac
116116

117-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
117+
CLASSPATH="\\\"\\\""
118118

119119

120120
# Determine the Java command to use to start the JVM.
@@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
213213
set -- \
214214
"-Dorg.gradle.appname=$APP_BASE_NAME" \
215215
-classpath "$CLASSPATH" \
216-
org.gradle.wrapper.GradleWrapperMain \
216+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
217217
"$@"
218218

219219
# Stop when "xargs" is not available.

samples/ktor-all-platforms-app/gradlew.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ goto fail
7070
:execute
7171
@rem Setup the command line
7272

73-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73+
set CLASSPATH=
7474

7575

7676
@rem Execute Gradle
77-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
77+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
7878

7979
:end
8080
@rem End local scope for the variables with windows NT shell

samples/ktor-all-platforms-app/server/src/main/kotlin/kotlinx/rpc/sample/Application.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fun Application.module() {
3030
}
3131
}
3232

33-
registerService<UserService> { ctx -> UserServiceImpl(ctx) }
33+
registerService<UserService> { UserServiceImpl() }
3434
}
3535
}
3636
}

samples/ktor-all-platforms-app/server/src/main/kotlin/kotlinx/rpc/sample/UserServiceImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import kotlinx.coroutines.flow.Flow
1111
import kotlinx.coroutines.flow.flow
1212
import kotlin.coroutines.CoroutineContext
1313

14-
class UserServiceImpl(override val coroutineContext: CoroutineContext) : UserService {
14+
class UserServiceImpl : UserService {
1515
override suspend fun hello(user: String, userData: UserData): String {
1616
return "Nice to meet you $user, how is it in ${userData.address}?"
1717
}

samples/ktor-all-platforms-app/server/src/test/kotlin/kotlinx/rpc/sample/ApplicationTest.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ import kotlinx.rpc.krpc.ktor.client.installKrpc
1212
import kotlinx.rpc.krpc.ktor.client.rpc
1313
import kotlinx.rpc.krpc.ktor.client.rpcConfig
1414
import kotlinx.rpc.krpc.serialization.json.json
15-
import kotlinx.rpc.krpc.streamScoped
1615
import kotlinx.rpc.withService
1716
import kotlin.test.Test
1817
import kotlin.test.assertEquals
1918

2019
class ApplicationTest {
2120
@Test
2221
fun testRoot() = testApplication {
22+
application {
23+
module()
24+
}
25+
2326
val service = createClient {
2427
installKrpc()
2528
}.rpc("/api") {

samples/ktor-all-platforms-app/shared/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
*/
44

55
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
6+
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
67
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
7-
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
88
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
99

1010
plugins {

samples/ktor-all-platforms-app/shared/src/commonMain/kotlin/UserService.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44

55
import kotlinx.coroutines.flow.Flow
6-
import kotlinx.rpc.RemoteService
76
import kotlinx.rpc.annotations.Rpc
87
import kotlinx.serialization.Serializable
98

@@ -14,7 +13,7 @@ data class UserData(
1413
)
1514

1615
@Rpc
17-
interface UserService : RemoteService {
16+
interface UserService {
1817
suspend fun hello(user: String, userData: UserData): String
1918

2019
fun subscribeToNews(): Flow<String>

samples/ktor-android-app/app/src/main/kotlin/kotlinx/rpc/sample/data/Client.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import kotlinx.rpc.krpc.ktor.client.rpc
1313
import kotlinx.rpc.krpc.ktor.client.rpcConfig
1414
import kotlinx.rpc.krpc.serialization.json.json
1515

16-
suspend fun createRpcClient(): RpcClient {
16+
fun createRpcClient(): RpcClient {
1717
return HttpClient(OkHttp) {
1818
installKrpc()
1919
}.rpc {

samples/ktor-android-app/app/src/main/kotlin/kotlinx/rpc/sample/ui/AppViewModel.kt

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package kotlinx.rpc.sample.ui
66

77
import androidx.lifecycle.ViewModel
88
import androidx.lifecycle.viewModelScope
9+
import kotlinx.coroutines.CoroutineScope
910
import kotlinx.rpc.sample.data.createRpcClient
1011
import kotlinx.rpc.sample.ui.state.WelcomeData
1112
import kotlinx.coroutines.Dispatchers
@@ -15,49 +16,40 @@ import kotlinx.coroutines.flow.MutableStateFlow
1516
import kotlinx.coroutines.flow.StateFlow
1617
import kotlinx.coroutines.launch
1718
import kotlinx.rpc.RpcClient
18-
import kotlinx.rpc.krpc.streamScoped
1919
import kotlinx.rpc.withService
2020
import kotlinx.rpc.sample.MyService
2121
import kotlinx.rpc.sample.UserData
2222

2323
class AppViewModel : ViewModel() {
24-
private var rpcClient: RpcClient? = null
25-
private var apiService: MyService? = null
24+
private val rpcClient: RpcClient = createRpcClient()
25+
private val apiService: MyService = rpcClient.withService<MyService>()
2626

2727
private val _uiState = MutableStateFlow<WelcomeData?>(null)
2828
val uiState: StateFlow<WelcomeData?> = _uiState
2929

3030
init {
3131
viewModelScope.launch(Dispatchers.IO) {
32-
rpcClient = createRpcClient()
33-
rpcClient?.let {
34-
apiService = it.withService()
35-
fetchData()
36-
}
32+
fetchData()
3733
}
3834
}
3935

40-
private fun fetchData() {
41-
viewModelScope.launch(Dispatchers.IO) {
42-
delay(2000)
43-
val greetingDeferred = async {
44-
apiService?.hello(
45-
"Alex",
46-
UserData("Berlin", "Smith")
47-
)
48-
}
49-
50-
val serverGreeting = greetingDeferred.await()
51-
52-
val allNews: MutableList<String> = mutableListOf()
53-
apiService?.subscribeToNews()?.collect {
54-
allNews += it
55-
56-
val sendNews = allNews.toMutableList() // fix ConcurrentModificationException
57-
serverGreeting?.let {
58-
_uiState.value = WelcomeData(serverGreeting, sendNews)
59-
}
60-
}
36+
private suspend fun CoroutineScope.fetchData() {
37+
delay(2000)
38+
val greetingDeferred = async {
39+
apiService.hello(
40+
"Alex",
41+
UserData("Berlin", "Smith")
42+
)
43+
}
44+
45+
val serverGreeting = greetingDeferred.await()
46+
47+
val allNews: MutableList<String> = mutableListOf()
48+
apiService.subscribeToNews().collect {
49+
allNews += it
50+
51+
val sendNews = allNews.toMutableList() // fix ConcurrentModificationException
52+
_uiState.value = WelcomeData(serverGreeting, sendNews)
6153
}
6254
}
6355
}

samples/ktor-android-app/common/src/main/kotlin/kotlinx/rpc/sample/MyService.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
package kotlinx.rpc.sample
66

77
import kotlinx.coroutines.flow.Flow
8-
import kotlinx.rpc.RemoteService
98
import kotlinx.rpc.annotations.Rpc
109

1110
@Rpc
12-
interface MyService : RemoteService {
11+
interface MyService {
1312
suspend fun hello(user: String, userData: UserData): String
1413

1514
fun subscribeToNews(): Flow<String>

samples/ktor-android-app/gradle/libs.versions.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
[versions]
2-
agp = "8.9.1"
3-
kotlin = "2.1.21"
2+
agp = "8.11.0-alpha07"
3+
kotlin = "2.2.0"
44
androidx-activityCompose = "1.10.1"
5-
androidx-appcompat = "1.7.0"
5+
androidx-appcompat = "1.7.1"
66
androidx-constraintlayout = "2.2.1"
77
androidx-core-ktx = "1.16.0"
88
androidx-test-junit = "1.2.1"
9-
compose = "1.7.8"
9+
compose = "1.8.3"
1010
compose-plugin = "1.5.14" # https://mvnrepository.com/artifact/androidx.compose.compiler/compiler
11-
compose-bom = "2025.04.00"
11+
compose-bom = "2025.06.01"
1212
material3 = "1.3.2"
1313
junit = "4.13.2"
14-
ktor = "3.1.2"
14+
ktor = "3.2.0"
1515
kotlinx-serialization-json = "1.8.1"
1616
kotlinx-coroutines-core = "1.10.2"
1717
logback = "1.5.18"
18-
kotlinx-rpc = "0.7.0"
18+
kotlinx-rpc = "0.8.0"
1919

2020
[libraries]
2121
# kotlin
Binary file not shown.

samples/ktor-android-app/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

samples/ktor-android-app/gradlew

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ case "$( uname )" in #(
114114
NONSTOP* ) nonstop=true ;;
115115
esac
116116

117-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
117+
CLASSPATH="\\\"\\\""
118118

119119

120120
# Determine the Java command to use to start the JVM.
@@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
213213
set -- \
214214
"-Dorg.gradle.appname=$APP_BASE_NAME" \
215215
-classpath "$CLASSPATH" \
216-
org.gradle.wrapper.GradleWrapperMain \
216+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
217217
"$@"
218218

219219
# Stop when "xargs" is not available.

samples/ktor-android-app/gradlew.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ goto fail
7070
:execute
7171
@rem Setup the command line
7272

73-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73+
set CLASSPATH=
7474

7575

7676
@rem Execute Gradle
77-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
77+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
7878

7979
:end
8080
@rem End local scope for the variables with windows NT shell

samples/ktor-android-app/server/src/main/kotlin/kotlinx/rpc/sample/Application.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fun Application.module() {
2424
}
2525
}
2626

27-
registerService<MyService> { ctx -> MyServiceImpl(ctx) }
27+
registerService<MyService> { MyServiceImpl() }
2828
}
2929
}
3030
}

samples/ktor-android-app/server/src/main/kotlin/kotlinx/rpc/sample/MyServiceImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import kotlinx.coroutines.flow.Flow
99
import kotlinx.coroutines.flow.flow
1010
import kotlin.coroutines.CoroutineContext
1111

12-
class MyServiceImpl(override val coroutineContext: CoroutineContext) : MyService {
12+
class MyServiceImpl : MyService {
1313
override suspend fun hello(user: String, userData: UserData): String {
1414
return "Nice to meet you $user, how is it in ${userData.address}?"
1515
}
@@ -22,4 +22,4 @@ class MyServiceImpl(override val coroutineContext: CoroutineContext) : MyService
2222
}
2323
}
2424
}
25-
}
25+
}

0 commit comments

Comments
 (0)