I'm trying to set up a Gradle build script for a new project. That project will use JPA 2 along with Querydsl.
On the following page of Querydsl's reference documentation, they explain how to set up their JPAAnnotationProcessor (apt) for Maven and Ant.
I would like to do the same with Gradle, but I don't know how and my beloved friend did not help me much on this one. I need to find a way to invoke Javac (preferably without any additional dependencies) with arguments to be able to specify the processor that apt should use (?)
The Querydsl Ant example should work pretty much as is when you take all the XML out. So it ends up being something like this:
src
,cp
andgenerated
you will probably be able to extract from Gradle.While I have no problem with the use gradle makes of Ant, I agree with the original poster that it is undesirable in this case. I found a github project by Tom Anderson here that describes what I believe is a better approach. I modified it a small amount to fit my needs (output to src/main/generated) so that it looks like:
This approach makes a lot more sense to me than the other, if it does to you too, then you have another option for querydsl generation.
Here is simple setup that works and integrates seamlessly with netbeans. Javac will basicly do all the job needed without much intervention. The rest are small treaks that will make it work with IDEs like Netbeans.
And that's it. Javac will make the rest of the job.
With Gradle 1.3 and newer (older not tested) you can use Querydsl APT like this:
These compiler args are passed directly to javac.
To use with groovy compiler replace
compileJava
withcompileGroovy
.I did not test it but this should work:
Hope it helps.
This guy's gist worked for me: https://gist.github.com/EdwardBeckett/5377401