-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Although I can generate the stubs with io.grpc:protoc-gen-grpc-kotlin I can't implement it #257
Comments
Sorry for terrible format. I added the code inside the "Insert Code" space created. I tried re-edit but I couldn't. Basically I added two main files: build.gradle that I downloaded from micronaut.launch and I have just added io.grpc:protoc-gen-grpc-kotlin |
@jeffbrown in case it helps, I tried copied all build.gradle from example provided to the project generated from Micronaut.Launch and I had the same issue. On another hand, the inverse works: I copied my proto file to the example provided and it works. This gives me a clue that there is something extra in the example provided that is mmissed in project generated from micronaut.launch |
If the example you are talking about is the one at github.com/micronaut-projects/micronaut-grpc/tree/c8ec599ad1b696d432efecb10145105074f3d26a/examples/hello-world-kotlin, be aware that project is using Micronaut |
@jeffbrown thanks. Well, my project is generated from Micronaut Laucher. I assume this is the best source for starting a fresh and up-to-date project with proper dependencie versions. Have you successfuly downloaded a grpc application from micronaut launcher and created successfully a proto and its endpoint in Kotlin? If so than would mind to share with me? |
modify
|
@morrle thanks, but same issue. May I ask you if you can share with me a very simple project evoulated from Micronaut Launcher with Kotlin? I am really stuck. I tried again. The steps are: 1 - I generated grpcApplication/kotlin from Micronaut Launcher.
3 - I tried to implement the proto example which came with autogenerated project
Here is the error when I tried gradle clean build Here is the whole build.gradle
The rest is exactly what I downloaded from micronaut launcher. |
Well, I am still looking forward to find a solution for this. Normally, we expected from frameworks launchers/initializers to be precise with dependencies. |
@jimisdrpc seems to be an issue specific to Kotlin, will investigate ... thanks for the report |
So the statement "Normally, we expected from frameworks launchers/initializers to be precise with dependencies." is inaccurate in that frameworks and launchers typically only include libraries and features when a stable release of a library is present and you are not using the raw output from the launcher, you are modifying the code to introduce |
@graemerocher ok, you are right. I didn't know protoc-gen-grpc-kotlin wasn't in stable version. As far as I can see, looking at https://mvnrepository.com/artifact/io.grpc/protoc-gen-grpc-kotlin I don't get this point. BTW, I can give a try with Java e remove this dependencie. |
@jimisdrpc Have you considered grpc-kotlin by Google? I used it with a Spring Boot project, and although not GA yet, it is doing a good job so far. |
@asarkar , thanks for suggestion. Good to know. I will give a try. It is worth to me as long as it runs well with Micronaut. |
@jimisdrpc i think this last error is because in your file .proto you write the "sendMethod" with the first letter in lower case, you should try write like this "SendMethod", i have the same error and i fix it with this change. |
@marcoscouto Naming in proto file is a convention, not a rule. If not following the convention results in an error, it’s a bug. |
@graemerocher Since December 8th I can say https://mvnrepository.com/artifact/io.grpc/protoc-gen-grpc-kotlin/1.0.0 is in stable version, right? Do you see any point in this build.gradle?
My goal is use protoc-gen-grpc-kotlin so the stubs will be generated in Kotlin with supend function (Coroutine context). |
Here is an example import com.google.protobuf.gradle.*
plugins {
id("org.jetbrains.kotlin.jvm") version "1.4.30"
id("org.jetbrains.kotlin.kapt") version "1.4.30"
id("org.jetbrains.kotlin.plugin.allopen") version "1.4.10"
id("com.github.johnrengelman.shadow") version "6.1.0"
id("io.micronaut.application") version "1.3.3"
id("com.google.protobuf") version "0.8.13"
}
version = "0.1"
group = "tmp"
val kotlinVersion=project.properties.get("kotlinVersion")
repositories {
mavenCentral()
jcenter()
}
micronaut {
testRuntime("junit5")
processing {
incremental(true)
annotations("tmp.*")
}
}
dependencies {
implementation("io.micronaut:micronaut-validation")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
implementation("io.micronaut.kotlin:micronaut-kotlin-runtime")
implementation("io.micronaut:micronaut-runtime")
implementation("io.micronaut.grpc:micronaut-grpc-runtime")
implementation("io.grpc:grpc-kotlin-stub:1.0.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2")
runtimeOnly("ch.qos.logback:logback-classic")
runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin")
testImplementation("io.micronaut:micronaut-http-client")
}
application {
mainClass.set("tmp.ApplicationKt")
}
java {
sourceCompatibility = JavaVersion.toVersion("1.8")
}
tasks {
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
sourceSets {
main {
java {
srcDirs("build/generated/source/proto/main/grpc")
srcDirs("build/generated/source/proto/main/java")
}
}
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.14.0"
}
plugins {
id("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:1.33.1"
}
id("grpckt") {
artifact = "io.grpc:protoc-gen-grpc-kotlin:1.0.0:jdk7@jar"
}
}
generateProtoTasks {
ofSourceSet("main").forEach {
it.plugins {
// Apply the "grpc" plugin whose spec is defined above, without options.
id("grpc")
id("grpckt")
}
}
}
} |
Issue: I can't implement an object autogenerated from protobuf.
How reproduce: generated a project from micronaut initializer with: gRPC Application type, Java 11, Kotlin. Add io.grpc:protoc-gen-grpc-kotlin on build.gradle, build it, add a controller and try implement GrpcdemoServiceGrpcKt.
build.gradle
gradle.properties
auto generated stubs while gradle build
All the rest are exactly the same from micronaut.launch
Possible solution: there is an example I downloaded and staret it successsfuly and called it from BloomRPC. It is from oficial examples. Looking at it I see a much more complex gradle.
Question: what I am missing in order to implement the autogenerated stubs? Do I need more gradle dependencies beyond io.grpc:protoc-gen-grpc-kotlin? Am I in right direction? If not, what should I do in order to implement the send rpc method from demo project downloaded from Micronaut.launch?
PS.: when I tried the most recent version from io.grpc:protoc-gen-grpc-kotlin gradle complains so I just use 0.1.2 which is the same from official example. This is not an issue for me as long as it is not related to my problem.
The text was updated successfully, but these errors were encountered: