Reputation: 4591
I have a project where the service
definition is in a separate file form the message definition. protoc doesn't like this:
Execution failed for task ':generateProto'.
> protoc: stdout: . stderr: IAscIndication.proto:11:13: "AscIndication" is not defined.
IAscIndication.proto:11:37: "AscResponse" is not defined.
(protoc is called from gradle).
Is this something one shouldn't do or a problem in our setup or a bug in protoc
(3.19.4)? It works when I combine both files in one.
The files in question:
IAscIndication.proto
syntax = "proto3";
import "Asc.proto";
package com.tyntec.hades.v1;
option java_multiple_files = true;
option java_package = "com.tyntec.hades.grpc";
service IAscIndication
{
rpc Asc(AscIndication) returns (AscResponse) {}
}
Asc.proto
syntax = "proto3";
import "BaseTypes.proto";
package tyntec.hades.v1;
option java_multiple_files = true;
option java_package = "com.tyntec.hades.grpc";
message AscRequest
{
SignalOutbound meta = 1;
AscRequestData data = 2;
}
message AscIndication
{
SignalInbound meta = 1;
AscRequestData data = 2;
}
And here is the cmdline and error when called from bash:
> /home/martinsc/.gradle/caches/modules-2/files-2.1/com.google.protobuf/protoc/3.19.4/99ed7588824cb00e0db4f1b215e7d4c69d00e74b/protoc-3.19.4-linux-x86_64.exe -I/home/martinsc/java/mt/acheron/src/main/proto -I/home/martinsc/java/mt/acheron/build/extracted-protos/main -I/home/martinsc/java/mt/acheron/build/extracted-include-protos/main --java_out=/home/martinsc/java/mt/acheron/src/generated/main/java --plugin=protoc-gen-grpc=/home/martinsc/.gradle/caches/modules-2/files-2.1/io.grpc/protoc-gen-grpc-java/1.44.1/5d42eec0c997038e3a131dea05ad9f5be37992cb/protoc-gen-grpc-java-1.44.1-linux-x86_64.exe --grpc_out=/home/martinsc/java/mt/acheron/src/generated/main/grpc /home/martinsc/java/mt/acheron/src/main/proto/Asc.proto /home/martinsc/java/mt/acheron/src/main/proto/BaseTypes.proto /home/martinsc/java/mt/acheron/src/main/proto/Error.proto /home/martinsc/java/mt/acheron/src/main/proto/IAscIndication.proto
IAscIndication.proto:11:13: "AscIndication" is not defined.
IAscIndication.proto:11:37: "AscResponse" is not defined.
System is Ubuntu 20.4.
Upvotes: 0
Views: 1686
Reputation: 1916
This is due to the package that doesn't match (probably a typo). In order to include another file they either need to be in the same package or you need to use the -I
option in protoc.
So in your case you probably need to change you Asc.proto
package to :
package com.tyntec.hades.v1;
or change your IAscIndication.proto
one to:
package tyntec.hades.v1;
If you do not want to change the packages, you have two possibilities:
protoc -I. [your_other_options] *.proto
rpc Asc(tyntec.hades.v1.AscIndication) returns (tyntec.hades.v1.AscResponse) {}
Upvotes: 3