ant文件
<?xml version="1.0" encoding="UTF-8"?><project name="newDemo" default="openExplorer" basedir="."><!--基础设置--><property name="project.name" value="newDemo" /><property name="src.dir" value="src" /><property name="web.dir" value="WebContent" /><property name="build.dir" value="${web.dir}/WEB-INF/classes" /><property name="lib.dir" value="${web.dir}/WEB-INF/lib" /><property name="dist.dir" value="dist" /><property name="dist.version" value="1.0.0" /><property name="tomcat.home" value="D:/Program Files/apache-tomcat-7.0.5/"/><!--类库路径--><path id="classpath"><fileset dir="${lib.dir}"><include name="**/*.jar" /></fileset></path><!--初始化--><target name="init"><echo message="beginning ant tasks" /></target><!--清除旧文件--><target name="clean" depends="init" description="remove all old files"><delete dir="${build.dir}" /><delete dir="${dist.dir}" /></target><!--新建编译目录--><target name="prepare" depends="clean"><echo message="mkdir WebContent/WEB-INF/classes" /><mkdir dir="${build.dir}" /></target><!--拷贝不需要编译的文件到build.dir--><target name="copy" depends="prepare" description="copy *.xml *.properties etc file to build path"><copy todir="${build.dir}" overwrite="true"><fileset dir="${src.dir}"><include name="**/*.xml" /><include name="**/*.properties" /><include name="**/*.xlsx" /></fileset></copy></target><!--编译源代码--><target name="complie" depends="copy" description="complies all src files"><javac srcdir="${src.dir}" destdir="${build.dir}" includes="**/*.java" encoding="UTF-8" debug="true"><classpath refid="classpath" /></javac><echo message="complie completed !" /></target><!--打包war包--><target name="war" depends="complie" description="compress war file"><mkdir dir="${dist.dir}" /><war warfile="${dist.dir}/newDemo.war"><fileset dir="${web.dir}"></fileset></war><echo message="build war ok...." /></target><!--将war包拷贝到tomcat/--><target name="copyTotomcat" depends="war" description="copy war to tomcat..."><copy todir="${tomcat.home}/webapps" overwrite="true"><fileset dir="${dist.dir}"><include name="**/*.war" /></fileset></copy><echo message="copy war to tomcat ok...." /></target><!--stop tomcat/--><target name="stopTomcat" depends="copyTotomcat"> <exec executable="${tomcat.home}/bin/shutdown.bat" spawn="true" vmlauncher="false"> <env key="CATALINA_HOME" value="${tomcat.home}" /> <arg line="/c start ${tomcat.home}/bin/shutdown.bat" /> </exec> <echo message="stop tomcat ok...." /></target> <!-- start tomcat/--><target name="startTomcat" depends="stopTomcat" description="tomcat starting....."> <exec executable="${tomcat.home}/bin/startup.bat" spawn="true" vmlauncher="false"> <env key="CATALINA_HOME" value="${tomcat.home}" /> <arg line="/c start ${tomcat.home}/bin/startup.bat" /> </exec> <echo message="start tomcat ok ...." /></target> <!-- open browser /--><target name="openExplorer" depends="startTomcat" description="tomcat starting....."> <exec executable="explorer"> <arg line="http://10.144.154.217:8080/newDemo"/></exec></target> </project>