Reputation: 35
As picture show above,my java project path is:
--stub-service
------src
--------main
----------java
----------proto
--------------helloworld.proto(1)
------stub-protocol
--------helloworld.proto(2)
and I want to generate target code by .proto file. The grpc tutorials are to build a hello world.proto file in src/main/proto, but my hello world.proto file in the sub-protocol.
How can I config .proto path in Java GRPC?
Upvotes: 2
Views: 1414
Reputation: 75
The protobuf plugin allows for this, although it is recommended that you use the standard convention.
Doc link: https://github.com/google/protobuf-gradle-plugin#configuring-protobuf-compilation
You can tell the proto plugin about your non standard proto dir by adding this to your build.gradle:
sourceSets {
main {
proto {
srcDir "${project.projectDir}/stub-protocol/"
}
}
}
Upvotes: 2