Open chrylis opened 9 years ago
Does javac only warn or does the code generation fail?
It's an actual compile error (perhaps this is using a pre-Java-7 compliant annotation-processing pathway), not just a warning, but it looks like the appropriate generated source and class exist. I'm not familiar enough with Querydsl to tell if there's anything wrong with them.
Reproduction (not quite minimal, but close) at https://github.com/chrylis/querydsl-apt-maven-plugin-47
Well, the problem is, as is found in the small print:
Instead, lombok applies the annotations and removes the references so that the error will never actually occur.
So you must use the lombok annotation processor together with the querydsl annotation processor.
This can be done in two ways:
<processor>
I hope this answers your question, and hope it helps others that run into the problem.
Hmm, interesting. For some reason (I don't know how it works), Lombok doesn't require specific configuration as an APT processor, or even as a Maven plugin.
I followed the instructions for making the Querydsl APT processor play nicely with m2e; if just omitting that plugin stanza entirely will work, then that would be great, and the docs on Querydsl+Eclipse are just out of date. However, it looks like the second solution as-is generates the source but doesn't get it compiled in an m2e build.
If you make a META-INF/services/javax.annotation.processing.Processor
file with the annotation processor in it javac will discover that, since it searches the classpath for annotation processors.
We also export that configuration, but the apt plugin enables more fine-grained configuration.
Hope it clears up some things.
CLI Maven picks up the SPI processor just fine, but m2e doesn't for some reason. Looks like the manual plugin configuration is still required to make m2e behave, and listing any additional processors being run will just have to be part of the SOP.
Lombok uses an odd hack to enable capturing annotations to be applied to generated code, which doesn't play nicely with the plugin:
The class appears to actually compile correctly later, but the plugin itself complains spuriously, and it might have trouble if a class with an
@__
annotation were also an entity.