<?xml version="1.0" encoding="UTF-8"?> <project name="technology" default="war" basedir="." > <property name="build_project" value="technology_ant"/> <property name="technology.home" value="F:/ssh/technology"/> <property name="technology.src" value="${technology.home}/src"/> <property name="technology.lib" value="${technology.home}/WebRoot/WEB-INF/lib"/> <property name="technology.jar" value="${technology.home}/WebRoot/WEB-INF/lib"/> <property name="technology.classes" value="${technology.home}/WEB-INF/classes"/> <property name="tomcat.home" value="D:/WebProject/apache-tomcat-6.0.24"/> <target name="init" depends="clean"> <path id="all"> <fileset dir="${technology.lib}"> <include name="**/*.jar"/> </fileset> <fileset dir="${tomcat.home}/lib"> <include name="*.jar"/> </fileset> </path> <mkdir dir="${build_project}/classes"/> </target> <target name="clean"> <delete dir="${build_project}"/> </target> <target name="compile" depends="init"> <javac srcdir="${technology.src}" destdir="${build_project}/classes" target="1.6" includeantruntime="on"> <classpath refid="all"></classpath> </javac> </target> <target name="war" depends="compile"> <war destfile="${tomcat.home}/webapps/technology.war" webxml="${technology.home}/WebRoot/WEB-INF/web.xml"> <fileset dir="${technology.home}" casesensitive="yes"> <include name="WEB-INF/**"/> <exclude name="*.war"/> </fileset> <fileset dir="${technology.home}" includes="**/**"/> <lib dir="${technology.home}/WebRoot/WEB-INF/lib"> <include name="*.jar"/> </lib> </war> </target> </project> 建立如上build.xml 转自: http://blog.csdn.net/shinn613/archive/2011/04/14/6322175.aspx