Reputation: 196
I am trying to compile my proto into a grpc java client and a python grpc java server. I can't get the java generated class to produce the Services. The following is proto named 'myproto.proto:
syntax = "proto3";
package amat.metrology_setup.api.services.generic_measurement;
option java_package = "amat.metrology_setup.api.services.generic_measurement";
message AlLData {
map<string, SingleData> map_data = 1;
}
message SingleData{
map<string, string> params = 1;
}
message Empty{
}
service Updaer {
rpc SendData(AlLData) returns (Empty);
rpc GetUpdatedData(Empty) returns (AlLData);
}
Python works well, but the java cannot geneate the matching Updaer. I've read that without the protoc-gen-grpc-java plugin it is expected not to generate services. Like this:
$protoc -I=$SRC_DIR --java_out=$DST_DIR $SRC_DIR/my_proto.proto
I know that I need grpc pluginprotoc-gen-grpc-java to generate the services and that wit
So i've done:
$protoc -I=$SRC_DIR --java_out=$DST_DIR --plugin=protoc-gen-grpc-java=$grpc_java_plugin $proto_file
But I still can't get the services to be compiled. All the paths are valid because the file is being compiled. what am I missing?
Upvotes: 0
Views: 448
Reputation: 40326
I'm running Linux AMD64 and:
myproto.proto
(including the typo in the service
name Updaer
) and;protoc-gen-grpc-java
from Maven.protoc
1 command as described in the comments1 As mentioned, for Java,
protoc
is commonly invoked using Maven, Gradle ...
ARCH="linux-x86_64"
VERS="1.64.0"
PLUGIN="protoc-gen-grpc-java-${VERS}-${ARCH}.exe"
wget \
https://repo1.maven.org/maven2/io/grpc/protoc-gen-grpc-java/${VERS}/${PLUGIN}
chmod +x ${PLUGIN}
Before:
.
├── myproto.proto
└── protoc-gen-grpc-java-1.64.0-linux-x86_64.exe
Then, I used the command as I described in the comment:
protoc \
--plugin=protoc-gen-grpc-java=${PLUGIN} \
--proto_path=${PWD} \
--java_out=${PWD} \
--grpc-java_out=${PWD} \
${PWD}/myproto.proto
After:
.
├── amat
│ └── metrology_setup
│ └── api
│ └── services
│ └── generic_measurement
│ ├── Myproto.java
│ └── UpdaerGrpc.java
├── myproto.proto
└── protoc-gen-grpc-java-1.64.0-linux-x86_64.exe
Upvotes: 0