<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="ITSSystem" default="main" basedir=".">
<property environment="env."/>
<property name="src.dir" value="${basedir}/src"/>
<property name="dest.dir" value="${basedir}/classes"/>
<property name="deploy.dir" value="${env.CATALINA_HOME}/webapps"/>
<property name="temp.dir" value="dist" />
<property name="root.dir" value="../" />
<property name="project.name" value="ITSSystem" />
<path id="compile.classpath">
<fileset dir="${basedir}/lib">
<include name="**/*.jar" />
</fileset>
</path>
<property name="path.string" refid="compile.classpath"/>
<echo message="${path.string}" />
<target name="init" >
<delete dir="${dest.dir}" />
<mkdir dir="${dest.dir}" />
</target>
<target name="compile" depends="init">
<javac srcdir="${src.dir}" destdir="${dest.dir}" classpathref="compile.classpath" />
<copy todir="${dest.dir}">
<fileset dir="${src.dir}">
<include name="**/*.xml" />
<include name="**/*.properties" />
</fileset>
</copy>
</target>
<target name="deploy" depends="compile">
<mkdir dir="${temp.dir}"/>
<mkdir dir="${temp.dir}/datafiles"/>
<mkdir dir="${temp.dir}/pages"/>
<mkdir dir="${temp.dir}/pages/img"/>
<mkdir dir="${temp.dir}/style"/>
<mkdir dir="${temp.dir}/WEB-INF"/>
<mkdir dir="${temp.dir}/WEB-INF/classes"/>
<mkdir dir="${temp.dir}/WEB-INF/lib"/>
<copy todir="${temp.dir}">
<fileset dir="${root.dir}">
<include name="**/*.*"/>
<exclude name="**/src/**" />
<exclude name="**/work/**" />
<exclude name="**/build.xml" />
</fileset>
</copy>
<jar destfile="${project.name}.war" basedir="${temp.dir}" />
<copy file="${project.name}.war" todir="${deploy.dir}" />
<delete file="${project.name}.war" failonerror="false"/>
<delete dir="${temp.dir}" failonerror="false" />
</target>
<!---------- backup src files in a zip file with a name of the current time --------updated on 29th Jan--------->
<tstamp>
<format property="name.backup" pattern="yyyyMMdd-HHmmss" />
</tstamp>
<target name="src.backup">
<delete>
<fileset dir="${basedir}" includes="*.zip"/>
</delete>
<zip destfile="${name.backup}.zip" basedir="${root.dir}/src" includes="**/*.java"/>
</target>
<target name="main" depends="deploy"/>
</project>
---------------------------------------->补充 关于sql Task<-------------------------------------------
build.xml
<project name="HibernateQuickly" default="main" basedir=".">
<property file="build.properties"/>
<property name="sql.dir" value="sql"/>
<path id="driver.path" location="lib/mysql-connector-java-3.2.0-alpha-bin.jar" />
<target name="createTables">
<sql driver="${mysql.dirver}"
url="${mysql.url}"
userid="${mysql.userid}"
password="${mysql.password}">
<classpath refid="driver.path"/>
<transaction src="${sql.dir}/Table_Speakers.sql" />
</sql>
</target>
<target name="main" depends="createTables"/>
</project>
build.properties
#MySQL Settings
mysql.dirver=org.gjt.mm.mysql.Driver
mysql.url=jdbc:mysql://192.168.227.65:3306/HibernateDB
mysql.userid=aaron
mysql.password=aaron