google / protobuf-gradle-plugin

Protobuf Plugin for Gradle
Other
1.73k stars 269 forks source link

How config proto src dir when proto files import by path #732

Closed louie-wh closed 3 months ago

louie-wh commented 10 months ago

for example I have a proto file at projectRoot/proto/hello.proto. the file content is :

syntax = "proto3";

option java_multiple_files = true;
option java_package = "io.grpc.dsl.hello";
option java_outer_classname = "HelloProto";
option objc_class_prefix = "HLW";

package hello;
import "message/msg.proto";
// The greeting service definition.
service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply) {}
}

and message dir is at projectRoot/message

build error Reason: Task ':lib_kotlindsl:generateDebugProto' uses this output of task ':lib_kotlindsl:mergeDebugJniLibFolders' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

this is my project git https://github.com/louie-wh/GrpcProto.git

ejona86 commented 10 months ago
            proto {
                srcDir("../")
                srcDir("../proto/")
            }

srcDir("../") will cause it to depend on all files in all projects. That is simply broken.

../proto/ is fine though. I suggest you move msg.proto within that folder. proto/message/msg.proto. Note that by convention your folder names should match the package names, so I'd suggest the names be proto/hello/msg.proto and proto/hello/hello.proto (or change the package names).

ejona86 commented 3 months ago

Seems like this is resolved. If not, comment, and it can be reopened.