Maven Java Source Code Generation for Hibernate
- by Adam
Hi,
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:
<target name="dbcodegen" depends="cleangen" description="Generate Java source from Hibernate XML">
<hibernatetool destdir="${src.generated}">
<configuration>
<fileset dir="${src.config}">
<include name="**/*.hbm.xml"/>
</fileset>
</configuration>
<hbm2java jdk5="true"/>
</hibernatetool>
</target>
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?
Thanks!
Adam.