You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
This is a known issue, which has been fixed on my branch long time ago. We rely quite heavily on protobuf namespaces and importing proto definitions from dependencies (both direct or transitive), and our version of plugin has been used to build production applications for over a year now. Please take a look at: https://github.com/sergei-ivanov/maven-protoc-plugin
I have just rolled out a new release with some additional functionality. Generated maven web site with mojo documentation is here: http://sergei-ivanov.github.com/maven-protoc-plugin/
I happened to check out your branch a few moments after I finished posting this bug and I'm very happy to see someone has picked up maintaining this plugin. All the work you've done is something I've wanted to tackle and you went much beyond what I had planned (namely: fixing this bug, writing integration tests and supporting m2e). I'd be happy to help contribute to your branch and eventually see this deployed onto Maven central. Let me know if you lack bandwidth to get there.
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.
The text was updated successfully, but these errors were encountered: