title: Setup Java 6 annotation processing configuration for eclipse compiler with maven
body: <p>What's the best way to setup the eclipse project compiler configuration for Java 6 annotation processors?</p>
  
  <p>My solution is to setup the <code>org.eclipse.jdt.apt.core.prefs</code> and <code>factorypath</code> files manually. This is a bit cumbersome:</p>
  
  <ul>
  <li>Reference the processor jar in the factorypath file</li>
  <li>Configure the eclipse annotation processor output directory <code>(org.eclipse.jdt.apt.genSrcDir</code> property in <code>org.eclipse.jdt.apt.core.prefs</code>)</li>
  <li>Add the eclipse annotation processor output directory as source folder</li>
  </ul>
  
  <p>One problem is that eclipse generated sources will be compiled with maven. Only <code>maven clean compile</code> is reliable as it removes the eclipse generated source files. (Eclipse and javac generated source files could be out of sync.)</p>
  
  <p>Is there are better solution to configure maven without eclipse generated source files at the maven source path?</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;project&gt;
    &lt;properties&gt;
      &lt;eclipse.generated.src&gt;${project.build.directory}/eclipse&lt;/eclipse.generated.src&gt;
    &lt;/properties&gt;
    &lt;build&gt;
        &lt;plugin&gt;
              &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
              &lt;artifactId&gt;build-helper-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;1.4&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                    &lt;id&gt;add-source&lt;/id&gt;
                    &lt;phase&gt;generate-sources&lt;/phase&gt;
                    &lt;goals&gt; &lt;goal&gt;add-source&lt;/goal&gt; &lt;/goals&gt;
                    &lt;configuration&gt;
                        &lt;sources&gt;
                          &lt;source&gt;${eclipse.generated.src}&lt;/source&gt;
                        &lt;/sources&gt;
                      &lt;/configuration&gt;
                &lt;/execution&gt;
              &lt;/executions&gt;
            &lt;/plugin&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-eclipse-plugin&lt;/artifactId&gt;
          &lt;configuration&gt;
            &lt;additionalConfig&gt;
              &lt;file&gt; &lt;name&gt;.factorypath&lt;/name&gt;
          &lt;content&gt;&lt;![CDATA[&lt;factorypath&gt;
    &lt;factorypathentry kind="VARJAR" id="M2_REPO/processor/processor.jar" enabled="true" runInBatchMode="false"/&gt;
    &lt;/factorypath&gt;
    ]]&gt;      &lt;/content&gt;
              &lt;/file&gt;
              &lt;file&gt;
                &lt;name&gt;.settings/org.eclipse.jdt.apt.core.prefs&lt;/name&gt;
          &lt;content&gt;&lt;![CDATA[
    eclipse.preferences.version=1
    org.eclipse.jdt.apt.aptEnabled=true
    org.eclipse.jdt.apt.genSrcDir=${eclipse.generated.src}
    org.eclipse.jdt.apt.reconcileEnabled=true
     ]]&gt;     &lt;/content&gt;
              &lt;/file&gt;
            &lt;/additionalConfig&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>