I am new to protocol Buffers. I have read the documentation and get a command to compile proto, but it only worked to compile single proto file.
protoc --proto_path=$ABSOLUTE_PATH --java_out=$OUT_SRC $MY_FILE.proto
After that, I tried to use wildcard to match all of proto files in the specified file path, but I get an error which is:
Could not make proto path relative: .proto: No such file or directory
Below is my env config
$ protoc --version
libprotoc 3.12.4
$ uname -v
#64-Ubuntu SMP Thu Jan 5 11:43:13 UTC 2023
I have tried the wildcard ,it is invalid.
protoc --proto_path=$ABSOLUTE_PATH --java_out=$OUT_SRC *.proto
protoc
is very particular about paths.
When you specify proto_path
's, you must then specify one of the proto_path
's for every *.proto
reference.
So, in your case:
protoc \
--proto_path=${ABSOLUTE_PATH} \
--java_out=$OUT_SRC \
${ABSOLUTE_PATH}/*.proto
Because you specified one proto_path
, every subsequent *.proto
reference must be explicitly reference against that path.
As a working model, I always use --proto_path=${PWD}
even if I only have a single proto (e.g. foo.proto
) in the working folder:
protoc \
--proto_path=${PWD} \
--xxx_out=... \
${PWD}/foo.proto