<!--
#  (c) Copyright 2007 David Calavera. 
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
-->
<project name="hibernateService" default="build-all" basedir=".">
	<description>
	</description>
	
	<property name="src.dir" value="src/java"/>
	<property name="ejb.dir" value="src/ejb"/>
	<property name="build.dir" value="build"/>
	<property name="libs.dir" value="lib"/>
	<property name="xml.dir" value="xml"/>
	<property name="dist.dir" value="dist"/>
	<property name="root.dir" value="../.."/>
	<property name="harfile" value="hibernateService.har"/>
	
	<path id="buildpath">
		<pathelement location="${libs.dir}/hibernate3.jar"/>
		<pathelement location="${libs.dir}/hibernate-tools.jar"/>
		<pathelement location="${libs.dir}/freemarker.jar"/>
		<pathelement location="${libs.dir}/commons-logging.jar"/>
		<pathelement location="${libs.dir}/commons-collections.jar"/>
		<pathelement location="${libs.dir}/dom4j.jar"/>
		<pathelement location="${libs.dir}/jboss-system.jar"/>
		<pathelement location="${libs.dir}/log4j.jar"/>
		<pathelement location="${libs.dir}/mysql-connector-java-5.0.3-bin.jar"/>
	</path>
	
	
	<target name="setup">
		<tstamp/>
		<mkdir dir="${build.dir}"/>
	</target>
	
	<target name="compile" depends="setup">
		<javac srcdir="${ejb.dir}" destdir="${build.dir}" classpathref="buildpath"/>
	</target>
	
	<target name="dist" depends="compile">
		<mkdir dir="${dist.dir}"/>

	<!-- build the WorkflowService MBean -->
        <jar destfile="${dist.dir}/${harfile}" >
        	<fileset dir="${xml.dir}">
	        	<include name="**/*.hbm.xml"/>
        	</fileset>
            <fileset dir="${build.dir}">
                <include name="**/*.class"/>
            </fileset>
             <metainf dir="${xml.dir}/META-INF">
                <include name="hibernate-service.xml"/>
            </metainf>
	</jar>		
	</target>
		
	<target name="build-all" depends="compile">
	</target>
	
	<taskdef name="hibernatetool" 
	         classname="org.hibernate.tool.ant.HibernateToolTask" 
	         classpathref="buildpath" />
	
	<target name="generate_classes">
		<input message="Please enter the hbm file (* for all files):" 
			addproperty="hbm.file" />
		
		<hibernatetool  destdir="${build.dir}/generated" >
			<configuration configurationfile="hibernate.cfg.xml"> 	
				<fileset dir="${xml.dir}">		 		
	    				<include name="**/${hbm.file}.hbm.xml"/>
				</fileset>
			</configuration>
						
			<hbm2ddl outputfilename="filename.sql" export="false" create="true" format="true"/>
			<hbm2java/>
		</hibernatetool>
	</target>
	
	
</project>
