grpc-kotlin
grpc-kotlin copied to clipboard
protoc-gen-grpckt is not recognized, on windows
Hi all
I am trying to generate some code from my protos, currently my build.gradle look like this
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.protobuf' version '0.8.18'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.example.foodshoppinglist"
minSdk 23
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
implementation("io.grpc:grpc-kotlin-stub:1.2.1")
implementation("io.grpc:grpc-protobuf:1.44.0")
implementation('com.google.protobuf:protobuf-kotlin:3.19.4')
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.19.4"
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:1.44.0"
}
grpck {
artifact = "io.grpc:protoc-gen-grpc-kotlin:1.2.1"
}
}
generateProtoTasks {
all().forEach {
it.plugins {
grpc
grpckt
}
it.builtins {
"kotlin"
}
}
}
}
I am running on windows 10, 64 bit. By no means i am any expert on this so i might be doing hundred of thing wrong. But when trying to rebuild project i get
Execution failed for task ':app:generateDebugProto'.
> protoc: stdout: . stderr: 'protoc-gen-grpckt' is not recognized as an internal or external command,
operable program or batch file.
--grpckt_out: protoc-gen-grpckt: Plugin failed with status code 1.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Does anyone have any idea what's wrong? Is there a bug or am i just doing everything wrong?
For the grpck artifact, try:
artifact = "io.grpc:protoc-gen-grpc-kotlin:1.2.1:jdk7@jar"
Tried it now, seems to give the same error
Odd. Can you try the examples and see if it works (ie ./gradlew :stub:build):
https://github.com/grpc/grpc-kotlin/tree/master/examples
That seems to work better:
PS C:\dev\grpc-kotlin\examples> ./gradlew :stub:build
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
BUILD SUCCESSFUL in 24s
17 actionable tasks: 7 executed, 10 up-to-date
Cool. How about from within Android Studio / IntelliJ?
Do you mean that i should open a terminal in Android Studio and run in there? if yes
C:\dev\grpc-kotlin\examples>gradlew :stub:build
BUILD SUCCESSFUL in 2s
17 actionable tasks: 17 up-to-date
Your original message made it seem like you were running the build from Android Studio (a menu). Can you run the build in the same way on the examples?
That seems to work, hmmm
Ok, so something different between the gradle setups. But it is hard to tell because of the differences between the groovy & kotlin build DSLs.
I'm starting to copy the stuff from the example-setup that seems necessary. Let's see where i end up
@diddiman
It may just be a typo, but isn't it grpck instead of grpckt?
↓ The following is an excerpt from the sample you provided.
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:1.44.0"
}
grpck {
artifact = "io.grpc:protoc-gen-grpc-kotlin:1.2.1"
}
}
@jamesward I am unable to get this working.
Is it not possible to get a simpler setup for Gradle?
@JavierSegoviaCordoba Here is a more basic project that might help you get things going: https://github.com/GoogleCloudPlatform/kotlin-samples/tree/main/run/grpc-hello-world-gradle
It also uses latest versions which changes some syntax in the build.