Skip to content

Commit 4dfc7e2

Browse files
committed
Initial gRPC project setup
1 parent 0fac7cc commit 4dfc7e2

File tree

9 files changed

+196
-13
lines changed

9 files changed

+196
-13
lines changed

build.gradle.kts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
6-
import util.configureApiValidation
7-
import util.configureNpm
8-
import util.configureProjectReport
96
import util.libs
7+
import util.configureProjectReport
8+
import util.configureNpm
9+
import util.configureApiValidation
1010

1111
plugins {
1212
alias(libs.plugins.serialization) apply false
1313
alias(libs.plugins.kotlinx.rpc) apply false
1414
alias(libs.plugins.conventions.kover)
15+
alias(libs.plugins.protobuf) apply false
1516
alias(libs.plugins.conventions.gradle.doctor)
1617
alias(libs.plugins.atomicfu)
1718
id("build-util")

gradle-conventions/common/src/main/kotlin/util/apiValidation.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
package util
@@ -14,12 +14,14 @@ fun Project.configureApiValidation() {
1414
the<ApiValidationExtension>().apply {
1515
ignoredPackages.add("kotlinx.rpc.internal")
1616
ignoredPackages.add("kotlinx.rpc.krpc.internal")
17+
ignoredPackages.add("kotlinx.rpc.grpc.internal")
1718

1819
ignoredProjects.addAll(
1920
listOf(
2021
"compiler-plugin-tests",
2122
"krpc-test",
2223
"utils",
24+
"protobuf-plugin",
2325
)
2426
)
2527

gradle-conventions/src/main/kotlin/conventions-publishing.gradle.kts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
import util.*
@@ -26,7 +26,8 @@ if (isPublicModule) {
2626
fun PublishingExtension.configurePublication() {
2727
repositories {
2828
configureSonatypeRepository()
29-
configureSpaceRepository()
29+
configureSpaceEapRepository()
30+
configureSpaceGrpcRepository()
3031
configureForIdeRepository()
3132
configureLocalDevRepository()
3233
}
@@ -110,12 +111,21 @@ fun MavenPom.configureMavenCentralMetadata() {
110111
}
111112
}
112113

113-
fun RepositoryHandler.configureSpaceRepository() {
114+
fun RepositoryHandler.configureSpaceEapRepository() {
114115
configureRepository(project) {
115116
username = "SPACE_USERNAME"
116117
password = "SPACE_PASSWORD"
117118
name = "space"
118-
url = "https://maven.pkg.jetbrains.space/public/p/krpc/maven"
119+
url = "https://maven.pkg.jetbrains.space/public/p/krpc/eap"
120+
}
121+
}
122+
123+
fun RepositoryHandler.configureSpaceGrpcRepository() {
124+
configureRepository(project) {
125+
username = "SPACE_USERNAME"
126+
password = "SPACE_PASSWORD"
127+
name = "grpc"
128+
url = "https://maven.pkg.jetbrains.space/public/p/krpc/grpc"
119129
}
120130
}
121131

grpc/grpc-core/build.gradle.kts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
plugins {
6+
alias(libs.plugins.conventions.kmp)
7+
alias(libs.plugins.kotlinx.rpc)
8+
}
9+
10+
kotlin {
11+
sourceSets {
12+
commonMain {
13+
dependencies {
14+
api(projects.core)
15+
api(projects.utils)
16+
api(libs.coroutines.core)
17+
}
18+
}
19+
20+
jvmMain {
21+
dependencies {
22+
implementation(libs.grpc.util)
23+
implementation(libs.grpc.stub)
24+
implementation(libs.grpc.protobuf)
25+
implementation(libs.grpc.kotlin.stub)
26+
implementation(libs.protobuf.java.util)
27+
implementation(libs.protobuf.kotlin)
28+
}
29+
}
30+
}
31+
}

grpc/grpc-core/gradle.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#
2+
# Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
#
4+
5+
kotlinx.rpc.excludeWasmWasi=true

protobuf-plugin/build.gradle.kts

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
6+
7+
plugins {
8+
alias(libs.plugins.conventions.jvm)
9+
alias(libs.plugins.kotlinx.rpc)
10+
alias(libs.plugins.serialization)
11+
alias(libs.plugins.protobuf)
12+
}
13+
14+
dependencies {
15+
implementation(libs.protobuf.java)
16+
17+
implementation(libs.slf4j.api)
18+
implementation(libs.logback.classic)
19+
20+
testImplementation(projects.grpc.grpcCore)
21+
testImplementation(libs.coroutines.core)
22+
testImplementation(libs.kotlin.test)
23+
24+
testImplementation(libs.grpc.stub)
25+
testImplementation(libs.grpc.netty)
26+
testImplementation(libs.grpc.protobuf)
27+
testImplementation(libs.grpc.kotlin.stub)
28+
testImplementation(libs.protobuf.java.util)
29+
testImplementation(libs.protobuf.kotlin)
30+
}
31+
32+
sourceSets {
33+
test {
34+
proto {
35+
exclude(
36+
"**/empty_deprecated.proto",
37+
"**/enum.proto",
38+
"**/example.proto",
39+
"**/funny_types.proto",
40+
"**/map.proto",
41+
"**/multiple_files.proto",
42+
"**/nested.proto",
43+
"**/one_of.proto",
44+
"**/options.proto",
45+
"**/with_comments.proto",
46+
)
47+
}
48+
}
49+
}
50+
51+
tasks.jar {
52+
manifest {
53+
attributes["Main-Class"] = "kotlinx.rpc.protobuf.MainKt"
54+
}
55+
56+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
57+
archiveClassifier = "all"
58+
59+
// Protoc plugins are all fat jars basically (the ones built on jvm)
60+
// be really careful of what you put in the classpath here
61+
from(
62+
configurations.runtimeClasspath.map { prop ->
63+
prop.map { if (it.isDirectory()) it else zipTree(it) }
64+
}
65+
)
66+
}
67+
68+
val buildDirPath: String = project.layout.buildDirectory.get().asFile.absolutePath
69+
70+
protobuf {
71+
protoc {
72+
artifact = libs.protoc.get().toString()
73+
}
74+
75+
plugins {
76+
create("kotlinx-rpc") {
77+
path = "$buildDirPath/libs/protobuf-plugin-$version-all.jar"
78+
}
79+
80+
create("grpc") {
81+
artifact = libs.grpc.protoc.gen.java.get().toString()
82+
}
83+
84+
create("grpckt") {
85+
artifact = libs.grpc.protoc.gen.kotlin.get().toString() + ":jdk8@jar"
86+
}
87+
}
88+
89+
generateProtoTasks {
90+
all().matching { it.isTest }.all {
91+
plugins {
92+
create("kotlinx-rpc") {
93+
option("debugOutput=$buildDirPath/protobuf-plugin.log")
94+
option("messageMode=interface")
95+
}
96+
create("grpc")
97+
create("grpckt")
98+
}
99+
100+
dependsOn(tasks.jar)
101+
}
102+
}
103+
}
104+
105+
kotlin {
106+
explicitApi = ExplicitApiMode.Disabled
107+
}
108+
109+
tasks.test {
110+
useJUnitPlatform()
111+
}

publishLocal.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/bin/bash
22

33
#
4-
# Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
4+
# Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
55
#
66

77
set -euxo pipefail
88

99
./gradlew publishAllPublicationsToBuildRepoRepository
10-
./gradlew -p compiler-plugin publishAllPublicationsToBuildRepoRepository
11-
./gradlew -p gradle-plugin publishAllPublicationsToBuildRepoRepository
10+
./gradlew -p compiler-plugin publishAllPublicationsToBuildRepoRepository --no-configuration-cache
11+
./gradlew -p gradle-plugin publishAllPublicationsToBuildRepoRepository --no-configuration-cache

settings.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
rootProject.name = "kotlinx-rpc"
@@ -34,6 +34,11 @@ dependencyResolutionManagement {
3434
includeBuild("compiler-plugin")
3535
}
3636

37+
includePublic(":protobuf-plugin")
38+
39+
include(":grpc")
40+
includePublic(":grpc:grpc-core")
41+
3742
includePublic(":bom")
3843

3944
includePublic(":utils")

versions-root/libs.versions.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ intellij = "233.13135.128"
2121
gradle-doctor = "0.10.0"
2222
kotlinx-browser = "0.3"
2323
shadow-jar = "9.0.0-beta4"
24+
grpc = "1.69.0"
25+
grpc-kotlin = "1.4.1"
26+
protobuf = "4.29.3"
27+
protobuf-gradle = "0.9.4"
2428

2529
# Stub versions – relpaced based on kotlin, mostly for gradle-related (plugins) dependencies
2630
# but also for dependencies for compiler-specific modules.
@@ -87,6 +91,19 @@ junit5-platform-launcher = { module = "org.junit.platform:junit-platform-launche
8791
junit5-platform-runner = { module = "org.junit.platform:junit-platform-runner" }
8892
junit5-platform-suite-api = { module = "org.junit.platform:junit-platform-suite-api" }
8993

94+
# grpc and protobuf
95+
protoc = { module = "com.google.protobuf:protoc", version.ref = "protobuf" }
96+
protobuf-java = { module = "com.google.protobuf:protobuf-java", version.ref = "protobuf" }
97+
protobuf-java-util = { module = "com.google.protobuf:protobuf-java-util", version.ref = "protobuf" }
98+
protobuf-kotlin = { module = "com.google.protobuf:protobuf-kotlin", version.ref = "protobuf" }
99+
grpc-stub = { module = "io.grpc:grpc-stub", version.ref = "grpc" }
100+
grpc-util = { module = "io.grpc:grpc-util", version.ref = "grpc" }
101+
grpc-netty = { module = "io.grpc:grpc-netty", version.ref = "grpc" }
102+
grpc-protobuf = { module = "io.grpc:grpc-protobuf", version.ref = "grpc" }
103+
grpc-kotlin-stub = { module = "io.grpc:grpc-kotlin-stub", version.ref = "grpc-kotlin" }
104+
grpc-protoc-gen-java = { module = "io.grpc:protoc-gen-grpc-java", version.ref = "grpc" }
105+
grpc-protoc-gen-kotlin = { module = "io.grpc:protoc-gen-grpc-kotlin", version.ref = "grpc-kotlin" }
106+
90107
# other
91108
kotlin-logging = { module = "io.github.oshai:kotlin-logging", version.ref = "kotlin-logging" }
92109
kotlin-logging-legacy = { module = "io.github.microutils:kotlin-logging", version.ref = "kotlin-logging" }
@@ -114,6 +131,7 @@ gradle-kotlin-dsl = { id = "org.gradle.kotlin.kotlin-dsl", version.ref = "gradle
114131
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
115132
gradle-plugin-publish = { id = "com.gradle.plugin-publish", version.ref = "gradle-plugin-publish" }
116133
shadow-jar = { id = "com.gradleup.shadow", version.ref = "shadow-jar" }
134+
protobuf = { id = "com.google.protobuf", version.ref = "protobuf-gradle" }
117135

118136
# gradle-conventions project
119137
conventions-common = { id = "conventions-common", version.ref = "kotlinx-rpc" }

0 commit comments

Comments
 (0)