Search code examples
protocol-buffersprotoc

Protocol buffers - only generating OuterClasses


I am trying to generate java source files from several proto files.

Im using Ubuntu 17.04.

I use the following shell script to do this:

for i in ./src/main/proto/my-protos; do
    [ -f "$i" ] || break
    protoc -I= ./src/main/proto/my-protos/ --java_out=./src/main/java/my/java/project ./$i  2>&1
done

I have also tried the following, where I specify the protoc-gen-grpc-java plugin:

protoc --plugin=./target/protoc-plugins/protoc-gen-grpc-java-1.4.0-linux-x86_64.exe --proto_path=./src/main/proto/my-protos/ --java_out=./src/main/java ./src/main/proto/my-protos/*.proto

In both cases the result is the same.

The problem is, these commands only generating XXXOuterClass.java files. There are no service classes, messages or stubs generated.

How can I generate all java classes using protoc?


Solution

  • I found the solution.

    Use the protoc-jar-maven-plugin - see https://github.com/os72/protoc-jar-maven-plugin/issues/47