Tried your hibernate-tag and it don't work. Here's my build.xml
Code:
<?xml version="1.0"?>
<!--
The DOCTYPE declaration declares the location of product-specific parts of the
Ant build file. You can change the values of these declarations to point to
other available files. This gives you an opportunity to choose what database
and EJB container to use for the Middlegen samples.
Note that this syntax has nothing to do with Ant or Middlegen. This
is the standard way defined by w3c to dynamically include external
files in an XML document. Any decent XML parser will do the include
transparently. Try to open this file in Internet Explorer and see
for yourself.
-->
<!DOCTYPE project [
<!ENTITY database SYSTEM "file:./config/database/oracle.xml">
<!ENTITY database SYSTEM "file:./config/database/hsqldb.xml">
<!ENTITY ejb SYSTEM "file:./config/ejb/jboss.xml">
<!--ENTITY ejb SYSTEM "file:./config/ejb/weblogic.xml"-->
<!--ENTITY ejb SYSTEM "file:./config/ejb/mvcsoft.xml"-->
]>
<project name="Middlegen Airlines" default="all" basedir=".">
<property file="${basedir}/build.properties"/>
<property name="name" value="airline"/>
<!-- This was added because we were several people (in a course) deploying to same app server>
<property environment="env"/>
<property name="unique.name" value="${name}.${env.COMPUTERNAME}"/-->
<property name="unique.name" value="${name}"/>
<property name="appxml.src.file" value="${basedir}/src/application.xml"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="src.dir" value="${basedir}/src"/>
<property name="java.src.dir" value="${src.dir}/java"/>
<property name="web.src.dir" value="${src.dir}/web"/>
<property name="build.dir" value="${basedir}/build"/>
<property name="build.java.dir" value="${build.dir}/java"/>
<property name="build.gen-src.dir" value="${build.dir}/gen-src"/>
<property name="build.gen-webui.dir" value="${build.dir}/gen-webui"/>
<property name="build.classes.dir" value="${build.dir}/classes"/>
<property name="build.ejb-meta.dir" value="${build.dir}/ejb-meta"/>
<property name="build.web-meta.dir" value="${build.dir}/web-meta"/>
<property name="ear.dir" value="${build.dir}/ear"/>
<property name="ear.file" value="${ear.dir}/${unique.name}.ear"/>
<property name="ear.meta.dir" value="${build.dir}/ear-meta"/>
<property name="ejb.dir" value="${build.dir}/ejb"/>
<property name="ejb.jar.file" value="${ejb.dir}/${unique.name}-ejb.jar"/>
<property name="war.dir" value="${build.dir}/war"/>
<property name="war.file" value="${war.dir}/${unique.name}-web.war"/>
<property name="build.html.dir" value="${build.dir}/html"/>
<property name="build.jdo.dir" value="${build.dir}/jdo"/>
<property name="build.xmi.dir" value="${build.dir}/xmi"/>
&database;
&ejb;
<!-- define the datasource.jndi.name in case the imported ejb file doesn't -->
<property name="datasource.jndi.name" value="${name}/datasource"/>
<path id="lib.class.path">
<pathelement path="${database.driver.classpath}"/>
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
<!-- The middlegen jars -->
<fileset dir="${basedir}/..">
<include name="*.jar"/>
</fileset>
</path>
<target name="init">
<available property="xdoclet1.2+" classname="xdoclet.modules.ejb.EjbDocletTask" classpathref="lib.class.path"/>
</target>
<!-- =================================================================== -->
<!-- Fails if XDoclet 1.2.x is not on classpath -->
<!-- =================================================================== -->
<target name="fail-if-no-xdoclet-1.2" unless="xdoclet1.2+">
<fail>
You must download several jar files before you can build Middlegen.
Execute the "download-deps" target. Then try to build again.
If you are behind a proxy, you should define the properties
http.proxyHost and http.proxyPort. Example:
ant -Dhttp.proxyHost=foo -Dhttp.proxyPort=bar
It's also possible to download the jars manually.
</fail>
</target>
<target name="download-deps" depends="setproxy">
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-1.2b2.jar" dest="${lib.dir}/xdoclet-1.2b2.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-apache-module-1.2b2.jar" dest="${lib.dir}/xdoclet-apache-module-1.2b2.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-bea-module-1.2b2.jar" dest="${lib.dir}/xdoclet-bea-module-1.2b2.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-ejb-module-1.2b2.jar" dest="${lib.dir}/xdoclet-ejb-module-1.2b2.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-hibernate-module-1.2b2.jar" dest="${lib.dir}/xdoclet-hibernate-module-1.2b2.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-jboss-module-1.2b2.jar" dest="${lib.dir}/xdoclet-jboss-module-1.2b2.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-jdo-module-1.2b2.jar" dest="${lib.dir}/xdoclet-jdo-module-1.2b2.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-jmx-module-1.2b2.jar" dest="${lib.dir}/xdoclet-jmx-module-1.2b2.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-libelis-module-1.2b2.jar" dest="${lib.dir}/xdoclet-libelis-module-1.2b2.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-mvcsoft-module-1.2b2.jar" dest="${lib.dir}/xdoclet-mvcsoft-module-1.2b2.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-solarmetric-module-1.2b2.jar" dest="${lib.dir}/xdoclet-solarmetric-module-1.2b2.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-tjdo-module-1.2b2.jar" dest="${lib.dir}/xdoclet-tjdo-module-1.2b2.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-web-module-1.2b2.jar" dest="${lib.dir}/xdoclet-web-module-1.2b2.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-xdoclet-module-1.2b2.jar" dest="${lib.dir}/xdoclet-xdoclet-module-1.2b2.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/xdoclet/jars/xdoclet-xjavadoc-1.2b2.jar" dest="${lib.dir}/xdoclet-xjavadoc-1.2b2.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/commons-collections/jars/commons-collections-2.1.jar" dest="${lib.dir}/commons-collections-2.1.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/commons-logging/jars/commons-logging-1.1-dev.jar" dest="${lib.dir}/commons-logging-1.1-dev.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/ejb/jars/ejb-2.0.jar" dest="${lib.dir}/ejb-2.0.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/hsqldb/jars/hsqldb-1.7.1.jar" dest="${lib.dir}/hsqldb-1.7.1.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/jdbc/jars/jdbc-2.0.jar" dest="${lib.dir}/jdbc-2.0.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/jdo/jars/jdo-1.0.jar" dest="${lib.dir}/jdo-1.0.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/log4j/jars/log4j-1.2.7.jar" dest="${lib.dir}/log4j-1.2.7.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/servletapi/jars/servletapi-2.3.jar" dest="${lib.dir}/servletapi-2.3.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/struts/jars/struts-1.0.2.jar" dest="${lib.dir}/struts-1.0.2.jar"/>
<get usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/velocity/jars/velocity-1.4-dev.jar" dest="${lib.dir}/velocity-1.4-dev.jar"/>
</target>
<target name="setproxy" if="http.proxyHost">
<setproxy proxyHost="http.proxyHost" proxyPort="http.proxyPort"/>
</target>
<!-- =================================================================== -->
<!-- Create tables -->
<!-- =================================================================== -->
<target
name="create-tables"
depends="init,fail-if-no-xdoclet-1.2,check-driver-present,panic-if-driver-not-present"
description="Create tables"
>
<echo>Creating tables using URL ${database.url}</echo>
<sql
classpath="${database.driver.classpath}"
driver="${database.driver}"
url="${database.url}"
userid="${database.userid}"
password="${database.password}"
src="${database.script.file}"
print="true"
output="result.txt"
/>
</target>
<target name="check-driver-present">
<available file="${database.driver.file}" type="file" property="driver.present"/>
</target>
<target name="panic-if-driver-not-present" unless="driver.present">
<fail>
The JDBC driver you have specified by including one of the files in ${basedir}/config/database
doesn't exist. You have to download this driver separately and put it in ${database.driver.file}
Please make sure you're using a version that is equal or superior to the one we looked for.
If you name the driver jar file differently, please update the database.driver.file property
in the ${basedir}/config/database/xxx.xml file accordingly.
</fail>
</target>
<!-- =================================================================== -->
<!-- Run Middlegen -->
<!-- =================================================================== -->
<target
name="middlegen"
description="Run Middlegen"
unless="middlegen.skip"
depends="init,fail-if-no-xdoclet-1.2,check-driver-present,panic-if-driver-not-present"
>
<mkdir dir="${build.gen-src.dir}"/>
<taskdef
name="middlegen"
classname="middlegen.MiddlegenTask"
classpathref="lib.class.path"
/>
<middlegen
appname="${name}"
prefsdir="${src.dir}"
gui="${gui}"
databaseurl="${database.url}"
initialContextFactory="${java.naming.factory.initial}"
providerURL="${java.naming.provider.url}"
datasourceJNDIName="${datasource.jndi.name}"
driver="${database.driver}"
username="${database.userid}"
password="${database.password}"
schema="${database.schema}"
catalog="${database.catalog}"
>
<table generate="true" name="ARTICLECOUNTRY_T" pktable="ARTICLECOUNTRY_T"/>
<table generate="true" name="ARTICLELANGUAGE_T" pktable="ARTICLELANGUAGE_T"/>
<table generate="true" name="COUNTRY_T" pktable="COUNTRY_T"/>
<table generate="true" name="CUSTOMERORDERLINE_T" pktable="CUSTOMERORDERLINE_T"/>
<table generate="true" name="CUSTOMERORDER_T" pktable="CUSTOMERORDER_T"/>
<table generate="true" name="CUSTOMER_T" pktable="CUSTOMER_T"/>
<table generate="true" name="DELIVERYADDRESS_T" pktable="DELIVERYADDRESS_T"/>
<table generate="true" name="STORE_T" pktable="STORE_T"/>
<table generate="true" name="STORESTOCK_T" pktable="STORESTOCK_T"/>
<!--
<table name="PERSON" pktable="id" singular="person" plural="persons" />
<table name="ADDRESS" pktable="id" singular="address" plural="addresses" />
-->
<hibernate
destination="${build.gen-src.dir}"
package="${name}.hibernate" javaTypeMapper="middlegen.plugins.hibernate.HibernateJavaTypeMapper"
/>
</middlegen>
<mkdir dir="${build.classes.dir}"/>
</target>
<target name="hbm2java" depends="middlegen" description="Generate .java from .hbm files.">
<taskdef name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="lib.class.path"/>
<hbm2java config="build\gen-src\airline\hibernate\hbm2java.cfg.xml" output="${src.dir}">
<fileset dir="config\sar\mapping">
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>
</target>
<!-- =================================================================== -->
<!-- Run Ejbdoclet on Middlegen-generated sources -->
<!-- =================================================================== -->
<target
name="ejbdoclet"
depends="middlegen"
>
<mkdir dir="${build.ejb-meta.dir}"/>
<taskdef
name="ejbdoclet"
classname="xdoclet.modules.ejb.EjbDocletTask"
classpathref="lib.class.path"
/>
<!-- first run xdoclet to generate facade objects only -->
<ejbdoclet
destdir="${build.gen-src.dir}"
excludedtags="@version,@author"
ejbspec="2.0"
>
<fileset dir="${build.gen-src.dir}">
<include name="**/ejb/**/*Bean.java" />
<exclude name="**/ejb/**/SeqBlockBean.java" />
<exclude name="**/ejb/**/SequenceBean.java" />
</fileset>
<packageSubstitution packages="ejb" substituteWith="interfaces"/>
<entityfacade>
</entityfacade>
</ejbdoclet>
<ejbdoclet
destdir="${build.gen-src.dir}"
excludedtags="@version,@author"
ejbspec="2.0"
>
<packageSubstitution packages="ejb" substituteWith="interfaces"/>
<fileset dir="${build.gen-src.dir}">
<include name="**/ejb/**/*Bean.java" />
<include name="**/ejb/**/*FacadeEJB.java" />
</fileset>
<utilobject kind="physical" includeGUID="true"/>
<localinterface/>
<localhomeinterface/>
<!--dataobject/-->
<valueobject/>
<remoteinterface/>
<homeinterface/>
<session/>
<entitypk/>
<entitycmp/>
<deploymentdescriptor
xmlencoding="ISO-8859-1"
destdir="${build.ejb-meta.dir}/META-INF"
validatexml="true"
/>
<weblogic
version="6.1"
xmlencoding="ISO-8859-1"
destdir="${build.ejb-meta.dir}/META-INF"
validatexml="true"
datasource="${datasource.jndi.name}"
createtables="true"
/>
<jboss
version="3.0"
xmlencoding="ISO-8859-1"
destdir="${build.ejb-meta.dir}/META-INF"
validatexml="true"
datasource="${datasource.jndi.name}"
datasourcemapping="${jboss.datasource.mapping}"
/>
<mvcsoft
xmlencoding="ISO-8859-1"
destdir="${build.ejb-meta.dir}/META-INF"
validatexml="true"
/>
</ejbdoclet>
</target>
<!-- =================================================================== -->
<!-- Run Webdoclet on Middlegen-generated sources -->
<!-- =================================================================== -->
<target
name="webdoclet"
depends="postprocess-ejb-jar"
>
<mkdir dir="${build.web-meta.dir}"/>
<taskdef
name="webdoclet"
classname="xdoclet.modules.web.WebDocletTask"
classpathref="lib.class.path"
/>
<webdoclet
destdir="${build.web-meta.dir}/WEB-INF"
excludedtags="@version,@author"
>
<fileset dir="${build.gen-src.dir}">
<include name="**/web/**/*.java" />
</fileset>
<deploymentdescriptor
servletspec="2.3"
validatexml="true"
mergedir="${basedir}/src/xdoclet"
/>
<weblogicwebxml
description="Web application for ${ant.project.name}"
/>
<strutsconfigxml
destdir="${build.web-meta.dir}/WEB-INF"
>
<configParam name="version" value="1.0"/>
</strutsconfigxml>
<!--webworkconfigproperties destdir="${build.ejb.classes.dir}"/-->
</webdoclet>
</target>
<!-- =================================================================== -->
<!-- Run Jdodoclet on Middlegen-generated sources -->
<!-- =================================================================== -->
<target
name="jdodoclet"
depends="middlegen"
>
<mkdir dir="${build.jdo.dir}/META-INF"/>
<taskdef
name="jdodoclet"
classname="xdoclet.modules.jdo.JdoDocletTask"
classpathref="lib.class.path"
/>
<jdodoclet
destdir="${build.classes.dir}"
excludedtags="@version,@author"
>
<fileset dir="${build.gen-src.dir}">
<include name="**/jdo/**/*.java" />
</fileset>
<jdometadata jdospec="1.0" generation="class"/>
<lido version="1.3"/>
<kodo version="2.3"/>
</jdodoclet>
</target>
<!-- =================================================================== -->
<!-- Make ear file -->
<!-- =================================================================== -->
<target
name="ear"
depends="war"
description="Make ear file"
>
<mkdir dir="${ear.meta.dir}/META-INF"/>
<copy todir="${ear.meta.dir}/META-INF" file="${appxml.src.file}">
<filterset>
<filter token="name" value="${unique.name}" />
<filter token="appname" value="${ant.project.name}" />
</filterset>
</copy>
<mkdir dir="${ear.dir}"/>
<ear
earfile="${ear.file}"
appxml="${ear.meta.dir}/META-INF/application.xml"
>
<fileset dir="${ejb.dir}"/>
<fileset dir="${war.dir}"/>
<fileset dir="${lib.dir}">
<include name="log4j*.jar"/>
</fileset>
</ear>
</target>
<!-- =================================================================== -->
<!-- Make war file -->
<!-- =================================================================== -->
<target name="war" depends="compile-web" description="Make ejb jar file">
<mkdir dir="${war.dir}"/>
<war
warfile="${war.file}"
webxml="${build.web-meta.dir}/WEB-INF/web.xml"
>
<classes dir="${build.classes.dir}">
<include name="**/web/**/*"/>
</classes>
<lib dir="${lib.dir}">
<include name="struts*.jar"/>
</lib>
<fileset dir="${build.web-meta.dir}">
<include name="WEB-INF/**/*"/>
<exclude name="WEB-INF/web.xml"/>
</fileset>
<fileset dir="${build.gen-webui.dir}">
<include name="**/*"/>
</fileset>
<fileset dir="${web.src.dir}">
<include name="**/*"/>
</fileset>
</war>
</target>
<!-- =================================================================== -->
<!-- Make ejb jar file -->
<!-- =================================================================== -->
<target name="ejb-jar" depends="compile-ejb" description="Make ejb jar file">
<mkdir dir="${ejb.dir}"/>
<jar
jarfile="${ejb.jar.file}"
>
<fileset dir="${build.classes.dir}">
<include name="**/ejb/**/*"/>
<include name="**/interfaces/**/*"/>
</fileset>
<fileset dir="${build.ejb-meta.dir}"/>
</jar>
</target>
<!-- =================================================================== -->
<!-- Compile business logic (ejb) -->
<!-- =================================================================== -->
<target name="compile-ejb" depends="ejbdoclet" description="Compile business logic (ejb)">
<javac
srcdir="${build.gen-src.dir}"
destdir="${build.classes.dir}"
classpathref="lib.class.path"
>
<include name="**/ejb/**/*"/>
<include name="**/interfaces/**/*"/>
</javac>
</target>
<!-- =================================================================== -->
<!-- Compile web -->
<!-- =================================================================== -->
<target name="compile-web" depends="webdoclet" description="Compile web">
<javac
srcdir="${build.gen-src.dir}"
destdir="${build.classes.dir}"
classpathref="lib.class.path"
>
<include name="**/web/**/*"/>
<include name="**/sql/**/*"/>
</javac>
</target>
<!-- =================================================================== -->
<!-- Compile business logic (jdo) -->
<!-- =================================================================== -->
<target name="compile-jdo" depends="jdodoclet" description="Compile business logic (jdo)">
<javac
srcdir="${build.gen-src.dir}"
destdir="${build.classes.dir}"
classpathref="lib.class.path"
>
<include name="**/jdo/**/*"/>
</javac>
</target>
<!-- =================================================================== -->
<!-- Build everything -->
<!-- =================================================================== -->
<target name="all" description="Build everything" depends="ear,compile-jdo"/>
<!-- =================================================================== -->
<!-- Clean everything -->
<!-- =================================================================== -->
<target name="clean" description="Clean all generated stuff">
<delete dir="${build.dir}"/>
</target>
<!-- =================================================================== -->
<!-- Brings up the hsqldb admin tool -->
<!-- =================================================================== -->
<target name="hsqldb-gui" description="Brings up the hsqldb admin tool">
<property name="database.urlparams" value="?user=${database.userid}&password=${database.password}"/>
<java
classname="org.hsqldb.util.DatabaseManager"
fork="yes"
classpath="${lib.dir}/hsqldb-1.7.1.jar;${database.driver.classpath}"
failonerror="true"
>
<arg value="-url"/>
<arg value="${database.url}${database.urlparams}"/>
<arg value="-driver"/>
<arg value="${database.driver}"/>
</java>
</target>
<!-- =================================================================== -->
<!-- generate a Clover html report -->
<!-- =================================================================== -->
<target name="clover">
<property name="cp" refid="lib.class.path"/>
<property name="cp2" value="${cp};${ant.home}/lib/clover.jar"/>
<java
classname="com.cortexeb.tools.clover.reporters.html.HtmlReporter"
fork="no"
classpath="${cp2}"
>
<arg line="-o ${build.dir}/clover -i C:/temp/clover/demo_coverage.db -t 'Middlegen coverage'"/>
</java>
</target>
<!-- =================================================================== -->
<!-- Deploys ear file -->
<!-- =================================================================== -->
<target name="deploy-ear" depends="ear" description="Deploys ear file">
<copy file="${ear.file}" todir="${deploy.dir}"/>
</target>
<!-- =================================================================== -->
<!-- Run hbm2java -->
<!-- =================================================================== -->
<target name="hbm2java" depends="middlegen" description="Generate .java from .hbm files.">
<taskdef
name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="lib.class.path"
/>
<hbm2java output="${build.gen-src.dir}">
<fileset dir="${build.gen-src.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>
</target>
</project>