-
Notifications
You must be signed in to change notification settings - Fork 133
Description
Say I have a project A which has a proto file stored in src/main/proto/company/a/a.proto;
package company.a;
message A {
optional int32 my_integer = 1;
}
Assuming everything works in A, the proto file is packaged into the resulting jar'ed artifact as such: company/a/a.proto
The real problem comes when a project B wants to depend upon the protos defined in project A:
src/main/proto/company/b/b.proto:
package company.b;
import "company/a/a.proto";
message B {
optional company.a.A my_a = 1;
}
In such cases, the build fails saying that a.proto cannot be found. It turns out that when the plugin extracts a.proto from the dependent jar to the temporary directory, it also adds a --proto_path option that essentially is target/protoc-dependencies/<obfuscated_jar_name>/company/a. This would require b.proto to import a.proto, which is confusing since it essentially flattens the namespace for all proto files.
The --proto_path really should be target/protoc-dependencies/<obfuscated_jar_name> instead. Since this might be a breaking change for some, I propose to introduce this behavior with a parameter (e.g. 'preserveDependencyStructure') that defaults to false. If you're interested, I have the change implemented on my local machine and it appears to work well.