Java – how to compile multiple proto files in a single command?

I have two proto files in a single directory, and I'm looking for a way to generate classes from these files in a single command The protobuf document says we need to use – proto_ Path parameter

C:\shekhar\proto_trial>dir
 Volume in drive C is C

 Directory of C:\shekhar\proto_trial

07/25/2014  12:16 PM    <DIR>          .
07/25/2014  12:16 PM    <DIR>          ..
07/25/2014  12:16 PM    <DIR>          java_op
07/25/2014  12:16 PM               230 map.proto
07/23/2014  04:24 PM               161 message.proto
07/25/2014  12:17 PM             1,228 response.proto
               3 File(s)          1,619 bytes
               3 Dir(s)  50,259,398,656 bytes free

I used – proto_ Path parameter, as shown below

C:\shekhar\proto_trial>protoc 
                       --proto_path=C:\shekhar\proto_trial 
                       --java_out=C:\shekhar\proto_trial\java_op 
                       *.proto

But I got the following mistakes

message.proto: File does not reside within any path specified using --proto_path (or -I). 
You must specify a --proto_path which encompasses this file. 
Note that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equivalent (it's harder than you think).

Please suggest some ways to compile all prototype files separately

Solution

The problem is that you will – proto_ Path is specified as absolute path, but proto file is specified as relative path You can delete – proto_ The path parameter (defaults to the current directory anyway), or you can do the following:

protoc --proto_path=C:\shekhar\proto_trial
       --java_out=C:\shekhar\proto_trial\java_op
       C:\shekhar\proto_trial\*.proto
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>