Here is one of my basic ant build files to generate mappings and schema exports from XDoclet comments in my .java files
Uli
Code:
<?xml version="1.0" encoding="UTF-8"?>
<project name="hibernatetest" default="hbmxdoclet2" basedir=".">
<property name="src" value="${basedir}/src"/>
<property name="build" value="${basedir}/bin"/>
<property name="lib" value="${basedir}/lib"/>
<property name="xdoclet.home" value="C:/Program Files/Java/xdoclet-1.2.3"/>
<property name="xdoclet2.home" value="C:/Program Files/Java/xdoclet-plugins-1.0.3"/>
<!-- generate .hbm.xml files from XDoclet comments in .java files -->
<target name="hbmxdoclet">
<taskdef name="hibernatedoclet" classname="xdoclet.modules.hibernate.HibernateDocletTask">
<classpath>
<fileset dir="${xdoclet.home}">
<include name="**/*.jar"/>
</fileset>
</classpath>
</taskdef>
<hibernatedoclet
destdir="${src}"
excludedtags="@version,@author,@todo"
force="true"
mergedir="${build}"
verbose="true">
<fileset dir="${src}">
<include name="**/*.java"/>
</fileset>
<hibernate version="3.0"/>
</hibernatedoclet>
</target>
<!-- generate sql DDL script from mapping files -->
<target name="schema">
<schemaexport
config="${src}/hibernate.cfg.xml"
quiet="no"
text="true"
drop="false"
delimiter=";"
output="schema-export.sql">
<fileset dir="${src}">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>
</target>
<!--
generate .hbm.xml files from XDoclet2 comments in .java files
necessary if you want to use Java 5 features such as generics
-->
<target name="hbmxdoclet2">
<path id="xdoclet2.task.classpath">
<fileset dir="${xdoclet2.home}">
<include name="**/*.jar" />
</fileset>
</path>
<taskdef
name="xdoclet"
classname="org.xdoclet.ant.XDocletTask"
classpathref="xdoclet2.task.classpath"
/>
<xdoclet>
<fileset dir="${src}">
<include name="**/*.java"/>
</fileset>
<component
classname="org.xdoclet.plugin.hibernate.HibernateMappingPlugin"
version="3.0"
destdir="${src}"
encoding="UTF-8"
/>
</xdoclet>
</target>
</project>