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

Compile error: Factory functions have the same name / namespace / package #13

Open
westito opened this issue Jun 11, 2024 · 2 comments
Open

Comments

@westito
Copy link

westito commented Jun 11, 2024

The factory function generated under the same package name and the same name as the Builder so it is ambiguous for the compiler. In my case the compiler try to use the private constructor of the original java generated code.

There should be an option for package name prefix or factory function name postfix. For ex. DataClassDtoFactory(...)

Képernyőfotó 2024-06-11 - 11 21 56

By the way: This plugin saves my live! 😄 The original generator should be like this.

@westito
Copy link
Author

westito commented Jun 11, 2024

Ah! I found the problem. I use option java_multiple_files = true; in proto file. When I turn it off, the problem goes. This is not really necessary for me so I leave it off, but you should mention this in docs, or handle by wrapping the factories in this case (in a *Factory outer class), so I could use DataFactory.DataClassDto for ex.

@be-hase
Copy link
Owner

be-hase commented Jun 19, 2024

@westito
Thank you for all the reports, they are very helpful.

I don't quite understand the problem, so could you share a proto file that reproduces the issue?
java_multiple_files = true; is working fine in my environment.
https://github.com/be-hase/protoc-gen-kotlin-ext/blob/main/functional-test/src/main/proto/example/all_type.proto#L6

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