Noel Yap
Noel Yap

Reputation: 19778

How to tell the protobuffer Gradle plugin not to generate protogen files?

I've created a proto plugin. When I execute:

$ protoc --plugin=protoc-gen-grpc-java=grpc-client-guice-gradle-plugin --grpc-java_out=build/generated/source/proto/client/java --proto_path=../snth-proto-definition/src/main/proto:../snth-proto-definition/build/extracted-include-protos/main ../snth-proto-definition/src/main/proto/snthnyap.proto

it generates the files I expect and only those files. But if I execute:

$ gradlew generateProto

extra files are created with the comment // Generated by the protocol buffer compiler. DO NOT EDIT!.

Is there a configuration setting to prevent these files from being generated?

Upvotes: 0

Views: 561

Answers (1)

Kun  Zhang
Kun Zhang

Reputation: 629

By default the protobuf plugin generates classes for the Protobuf messages. If you don't want it, put this in your build.gradle:

protobuf {
  generateProtoTasks {
    all().each { task ->
      task.builtins {
        remove java
      }
    }
  }
}

Upvotes: 1

Related Questions