Closed magick93 closed 6 years ago
${basedir}
is an absolute path, and I suspect that by adding it into the include pattern you are effectively excluding everything, because nothing will match it. Includes/excludes are needed very seldom, only for some non-trivial source directory layouts.<proto_root>/my/package/xxx.proto
. Again, you are making your life more difficult by introducing packages, and again I advise you to get a properly working project configuration without any excessive customisations and only then start tweaking things. Otherwise you are wasting time of other people who end up doing your homework for you. I am happy to help with non-trivial problems, but most of your problems could be resolved by reading the relevant documentation and not trying to complicate things without necessity.-X
, it will output a lot of useful debug information that might be helpful in figuring out what is being passed to protoc.By going against the convention and placing your proto files in a custom root you are making your life harder for no good reason.
you should always try to stick to maven conventions and avoid unnecessary customisations
Surely sticking to maven conventions would mean using the resource
folder for proto files, rather than adding a proto
folder to main? Proto files are not source code, but are resources used to transpile to source code.
Proto files are NOT a java file. They are used to generate source files - eg, java, c++, php etc. We use a custom folder as we us git submodules - we clone a git repo of proto files into the proto directory. These proto files are also used in other projects. I'm sure this is not that usual. Having an inflexible system that doesnt cater to using custom folders is what is going against convention.
Again, you are making your life more difficult by introducing packages,
As mentioned above, protos are essentially contracts - meaning they are not always up for change.
Before opening bugs against maven plugin, please make sure your proto files can be compiled by protoc on the command line.
Yes the files can be compiled using cli.
Anyway, I was able to solve this issue using https://github.com/os72/protoc-jar-maven-plugin
Sources vs. resources and compiling vs. transpiling is a philosophical and/or linguistic debate and I have little desire to go there. Suffice to say that:
a) quite a few code generating maven plugins use src/main/xxx
by default for their inputs;
b) this plugin is over 5 years old, and some decisions were taken long time ago and by other people, and I don't want to change the existing conventions unnecessarily for no good reason and break backwards compatibility for the existing users.
Also, I had customers/users with non-trivial configurations, including git submodules, packages and includes/excludes. There is enough flexibility in this maven plugin to achieve the desired effect. As it is generally the case with Maven, there's a certain degree of flexibility, but it is often intentionally limited, so that the users are discouraged from going radically against the conventions and creating monstrous build configurations. If one finds themselves fighting Maven, then they are either doing it wrong and in an un-Maven way, or they need a more suitable tool for the job, perhaps Gradle.
I am glad you managed to solve your problem with an alternative tool, which fits into the "use the most approprate tool for the job" philosophy. Good luck with your project!
hello
I am trying to generate using protos that are not in the default folder.
The basic summary of the problem is: When I have:
Then I get:
However, if I have:
Then it fails to find messages, and complains about messages not being found.
When I do so. the maven plugin cannot find related proto files that are in the same directory. If I specify the location of the proto files using
protoSourceRoot
directive, it makes no difference.When I specify the folder using the Include directive, the generator does not error, but does not generate anything.