The key is to use the <taskdef's classpath> to get the .hbm.xml and
.class files into the class path. So something like this.
<property name="build.classes.dir" location="${build.dir}/classes"/>
<property name="generated.classes.dir" location="${build.dir}/generated"/>
<path id="project.classpath">
<fileset refid="hibernate.jar.fileset"/> // Location of hibernate2.jar
<fileset refid="hibernate.dependancy.fileset"/> // H2's lib jars
<fileset refid="xdoclet.fileset"/> // location of xdoclet's jar
</path>
<path id="schema.export.classpath">
<path refid="project.classpath" />
<fileset refid="mysql.fileset"/> // MySQL driver
<pathelement location="${generated.classes.dir}"/> // Hbm files here
<pathelement location="${build.classes.dir}"/> // Compiles .class
files here
</path>
<target name="schemaexport" depends="compile">
<taskdef name="schemaexport"
classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="schema.export.classpath"/>
<schemaexport config="${generated.classes.dir}/hibernate.cfg.xml" />
</target> |