hibernate - How do you integrate the java annotation processor into the java plugin -


i have project laid out follows:

src/ java generated 

src/java contains jpa entities , query classes use jpa metamodel classes generated hibernate metamodel annotation processor.

what best way incorporate annotation processing java plugin?

i have following task defined, has task dependency on compilejava fail because of code dependent on classes generated annotation processor.

task processannotations(type: compile) { gendir = new file("${projectdir}/src/generated") gendir.mkdirs() source = ['src/java'] classpath = sourcesets.test.compileclasspath destinationdir = gendir options.compilerargs = ["-proc:only"] } 

the reason why processannotations depends on compilejava put test compile class path on former task's compile class path, , test compile class path contains compiled production code (i.e. output of compilejava).

as how best solve problem @ hand, shouldn't need separate compile task. java compiler can invoke annotation processors , compile generated sources (along original sources) in 1 pass (see annotation processing). 1 thing you'll need put annotation processor on compile class path:

configurations { hibernateannotationprocessor } dependencies { hibernateannotationprocessor "org.hibernate: ..." } compilejava.compileclasspath += configurations.hibernateannotationprocessor 

(you don't want add annotation processor compile configuration because considered dependency of production code.)

from can tell, there (assuming using jdk6 or higher).


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -