Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin doesn't preserve directory structure in dependencies #20

Open
jsilland opened this issue Jan 4, 2013 · 2 comments
Open

Plugin doesn't preserve directory structure in dependencies #20

jsilland opened this issue Jan 4, 2013 · 2 comments

Comments

@jsilland
Copy link

jsilland commented Jan 4, 2013

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.

@sergei-ivanov
Copy link

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/

@jsilland
Copy link
Author

jsilland commented Jan 6, 2013

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants