I have a gradle muliproject. The root project holds protobuf sources. But when I want to use it in JsonToGrpc filter of SpringCloud Gateway, I need to provide the proto-descriptor file and the proto-file file, how can I specify them in the gateway's configuration?
D:. <- the root project
├─.gradle
├─build
│ ├─classes
│ │ ├─java
│ │ │ └─main
│ | | └─cn.remering.kluster.grpc
│ │ └─kotlin
│ │ └─main
│ | ├─cn.remering.kluster.grpc
│ │ └─META-INF
│ └─generated
│ └─source
│ └─proto
│ └─main
│ ├─grpc
│ │ └─cn.remering.kluster.grpc
│ ├─grpckt
│ │ └─cn.remering.kluster.grpc
│ ├─java
│ │ └─cn.remering.kluster.grpc
│ ├─kotlin
│ | └─cn.remering.kluster.grpc
| └-descriptor_set.desc <--- the proto-descriptor file
├─gradle
│ └─wrapper
├─kluster-skin-auth
| |
│ └─src
│ ├─main
│ │ ├─kotlin
│ │ │ └─cn.remering.kluster.auth.api
│ │ └─resources
│ └─test
│ ├─kotlin
│ └─resources
├─kluster-skin-gateway <-- the gateway
│ ├─build
│ │ ├─classes
│ │ │ └─kotlin
│ │ │ └─main
│ │ │ ├─cn.remering.kluster.gateway
│ │ │ └─META-INF
│ │ └─resources
│ │ └─main
│ └─src
│ ├─main
│ │ ├─kotlin
│ │ │ └─cn.remering.kluster.gateway
│ │ └─resources
│ └─test
│ ├─kotlin
│ └─resources
└─src
└─main
└─proto <-- contains the proto-file
build.gradle.kts of the root project
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
extra["springCloudVersion"] = "2023.0.0"
extra["springCloudAlibabaVersion"] = "2022.0.0.0"
plugins {
id("org.springframework.boot") version "3.2.3" apply false
kotlin("jvm") version "1.9.22"
id("com.google.protobuf") version "0.9.4"
kotlin("plugin.spring") version "1.9.22" apply false
}
sourceSets {
main {
proto {
srcDir("src/main/proto")
}
}
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.25.3"
}
plugins {
create("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:1.62.2"
}
create("grpckt") {
artifact = "io.grpc:protoc-gen-grpc-kotlin:1.4.1:jdk8@jar"
}
}
generateProtoTasks {
all().configureEach {
generateDescriptorSet = true
plugins {
create("grpc")
create("grpckt")
}
builtins {
create("kotlin")
}
}
}
}
allprojects {
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "org.jetbrains.kotlin.plugin.spring")
repositories {
mavenCentral()
}
dependencies {
val implementation by configurations
val api by configurations
val compileOnly by configurations
implementation("io.grpc:grpc-protobuf:1.62.2")
implementation("io.grpc:grpc-kotlin-stub:1.4.1")
implementation("com.google.protobuf:protobuf-kotlin:3.25.3")
compileOnly("jakarta.annotation:jakarta.annotation-api:1.3.5")
}
tasks.withType<Copy> {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
subprojects {
apply(plugin = "org.springframework.boot")
apply(plugin = "io.spring.dependency-management")
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "org.jetbrains.kotlin.plugin.spring")
dependencies {
val implementation by configurations
val testImplementation by configurations
implementation(rootProject)
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
implementation(platform("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}"))
implementation(platform("com.alibaba.cloud:spring-cloud-alibaba-dependencies:${property("springCloudAlibabaVersion")}"))
implementation("org.springframework.cloud:spring-cloud-starter")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("io.github.microutils:kotlin-logging-jvm:2.0.11")
implementation("org.springframework.cloud:spring-cloud-starter-bootstrap")
implementation("com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery")
implementation("com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-config")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
jvmTarget = "17"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
}
group = "cn.remering.kluster"
version = "1.0-SNAPSHOT"
application.yaml of the gateway
spring:
cloud:
gateway:
routes:
- id: auth-service
uri: grpc://kluster-skin-auth
predicates:
- Path=/auth/**
filters:
- name: JsonToGrpc
args:
proto-descriptor: file:<unknown>
proto-file: file:<unkown>
service: AuthService
method: authenticate
I asked the ChatGPT 3.5 and still don't know how to refer the proto-descriptor file and proto-filefile.