title: How do you integrate the java annotation processor into the java plugin
body: <p>I have a project that is laid out as follows:</p>
  
  <pre><code>src/
    java
    generated
  </code></pre>
  
  <p>src/java contains jpa entities and query classes that use the jpa metamodel classes that are generated by the <a href="http://www.hibernate.org/subprojects/jpamodelgen.html" rel="nofollow">hibernate metamodel annotation processor</a>.</p>
  
  <p>What is the best way to incorporate annotation processing into the java plugin?</p>
  
  <p>I currently have the following task defined, but it has a task dependency on compileJava which will fail because some of the code is dependent on the classes that are generated by the annotation processor.</p>
  
  <pre><code>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"]
  }
  </code></pre>