title: Maven Java Source Code Generation for Hibernate
body: <p>I´m busy converting an existing project from an Ant build to one using Maven.  Part of this build includes using the hibernate hbm2java tool to convert a collection of .hbm.xml files into Java.  Here's a snippet of the Ant script used to do this:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;target name="dbcodegen" depends="cleangen" 
          description="Generate Java source from Hibernate XML"&gt;
    &lt;hibernatetool destdir="${src.generated}"&gt;
      &lt;configuration&gt;   
        &lt;fileset dir="${src.config}"&gt;
          &lt;include name="**/*.hbm.xml"/&gt;
        &lt;/fileset&gt;
      &lt;/configuration&gt;   
      &lt;hbm2java jdk5="true"/&gt;
    &lt;/hibernatetool&gt;   
  &lt;/target&gt;
  </code></pre>
  
  <p>I've had a look around on the internet and some people seem to do this (I think) using Ant within Maven and others with the Maven plugin.  I'd prefer to avoid mixing Ant and Maven.  Can anyone suggest a way to do this so that all of the .hbm.xml files are picked up and the code generation takes place as part of the Maven code generation build phase?</p>
  
  <p>Thanks!</p>
  
  <p>Adam.</p>