Answer the question
In order to leave comments, you need to log in
How to generate Protobuf in Java?
Hello everyone! I am almost new to both Java and Kotlin, but I have been working with buffer protocols for a long time. There is no way to correctly generate files through protoc, as unnecessary subfolders are created. Let's say I want the generated files to be in a package com.example.pb.test
, and they are created in com.example.pb.test.test
the Project Structure like this:
Makefile in the pb folder:
compile:
protoc --java_out=tutorial --kotlin_out=tutorial test.proto
syntax = "proto3";
package tutorial;
option java_package = "tutorial";
option java_outer_classname = "AddressBookProtos";
message Person {
optional string name = 1;
optional int32 id = 2;
optional string email = 3;
enum PhoneType {
MOBILE = 0;
HOME = 1;
WORK = 2;
}
message PhoneNumber {
optional string number = 1;
optional PhoneType type = 2;
}
repeated PhoneNumber phones = 4;
}
message AddressBook {
repeated Person people = 1;
}
com.lightswitch.contesttest.pb.tutorial
, but in this case the whole name is duplicated
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question