build.xml
<?xml version="1.0" encoding="UTF-8"?> <project name="AntWebDemo" basedir="." default="main"> <property file="build.properties" /> <target name="clean"> <delete dir="${classes.dir}" /> <delete dir="${build.dir}" /> <delete dir="${tomcat.home}/webapps" /> <delete dir="${tomcat.home}/work" /> </target> <target name="init"> <mkdir dir="${classes.dir}" /> <mkdir dir="${build.dir}" /> <mkdir dir="${tomcat.home}/webapps" /> <mkdir dir="${tomcat.home}/work" /> </target> <target name="compile" depends="init"> <javac srcdir="${src.dir}/main" destdir="${classes.dir}" /> <mkdir dir="${build.dir}/test" /> <javac srcdir="${src.dir}/test" destdir="${build.dir}/test" /> </target> <path id="classpath"> <fileset dir="${external-lib}" includes="**/*.jar" /> </path> <target name="war" depends="init"> <mkdir dir="${build.dir}/war" /> <war warfile="${build.dir}/war/${ant.project.name}.war" webxml="${web-inf.dir}/web.xml"> <lib dir="${lib.dir}" /> <classes dir="${classes.dir}" /> <fileset dir="${webroot.dir}" /> </war> </target> <target name="publish" depends="war"> <copy todir="${tomcat.home}/webapps"> <fileset dir="${build.dir}/war" includes="${ant.project.name}.war" /> </copy> </target> <target name="main" depends="clean,publish"> </target> </project>