title: Generate the JPA metamodel files using maven-processor-plugin - What is a convenient way for re-generation?
body: <p>I am trying to use maven-processor-plugin for generating JPA metamodel java files and I set up my pom.xml as belows. </p>
  
  <pre><code>&lt;plugin&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;configuration&gt;
              &lt;source&gt;1.8&lt;/source&gt;
              &lt;target&gt;1.8&lt;/target&gt;
              &lt;compilerArgument&gt;-proc:none&lt;/compilerArgument&gt;
          &lt;/configuration&gt;
      &lt;/plugin&gt;
      &lt;plugin&gt;
          &lt;groupId&gt;org.bsc.maven&lt;/groupId&gt;
          &lt;artifactId&gt;maven-processor-plugin&lt;/artifactId&gt;
          &lt;executions&gt;
              &lt;execution&gt;
                  &lt;id&gt;process&lt;/id&gt;
                  &lt;goals&gt;
                      &lt;goal&gt;process&lt;/goal&gt;
                  &lt;/goals&gt;
                  &lt;phase&gt;generate-sources&lt;/phase&gt;
                  &lt;configuration&gt;
                      &lt;!-- source output directory --&gt;
                      &lt;outputDirectory&gt;${basedir}/src/main/java&lt;/outputDirectory&gt;
                      &lt;processors&gt;
                          &lt;processor&gt;org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor&lt;/processor&gt;
                      &lt;/processors&gt;
                      &lt;overwrite&gt;true&lt;/overwrite&gt;
                  &lt;/configuration&gt;
              &lt;/execution&gt;
          &lt;/executions&gt;
      &lt;/plugin&gt;
  </code></pre>
  
  <p>Actually, I want to generate metamodel files (Entity_.java) to the same packages of their corresponding entities (Entity.java). Hence, I set up outputDirectory in the plugin as </p>
  
  <pre><code>&lt;outputDirectory&gt;${basedir}/src/main/java&lt;/outputDirectory&gt;
  </code></pre>
  
  <p>The first time of running is ok, but from later times when performing the metamodel java files re-generation, the plugin always turns out an error about file duplication.</p>
  
  <p>My Question is 
  - Is there any way to config the plugin so that it could overwrite the existing files during re-generation?</p>
  
  <p>In fact, to work around</p>
  
  <ol>
  <li>I must delete all generated files before any re-generation.</li>
  <li>I could point the outputDirectory to a different folder in /target, this location will be clean everytime Maven run, but this
  leads to manually copy generated metamodel files to source folder
  for update after re-generation.</li>
  </ol>
  
  <p>Both of these are very inconvenient and I hope you guys could show me a proper solution.</p>