日期:2014-05-19 浏览次数:20773 次
<?xml version="1.0" encoding="UTF-8"?> <!--工程名build默认执行delete任务--> <project name="build" default="clean"> <!--设置变量并赋值--> <!--设置工程名--> <property name="project.name" value="test" /> <!--源项目位置--> <property name="project" value="D:/work/test" /> <property name="project.web" value="${project}/WebContent" /> <property name="project.src" value="${project}/src" /> <!--配置文件目录--> <property name="project.src.config" value="${project.src}/config" /> <!--lib目录位置--> <property name="project.lib" value="${project}/WebContent/WEB-INF/lib" /> <!--目标项目位置--> <property name="build" value="D:/build" /> <property name="build.web" value="${build}/web" /> <property name="build.web.classess" value="${build.web}/WEB-INF/classes" /> <property name="build.web.lib" value="${build.web}/WEB-INF/lib" /> <!--war文件位置--> <property name="war.name" value="${project.name}.war" /> <property name="war" value="D:/${war.name}" /> <!--设置jar包路径 --> <path id="jar.path"> <fileset dir="${project.lib}"> <include name="**/*.jar" /> </fileset> </path> <!--建立build文件夹--> <target name="init"> <mkdir dir="${build}" /> <mkdir dir="${build.web}" /> <mkdir dir="${build.web.classess}" /> <mkdir dir="${build.web.lib}" /> </target> <!--将源项目文件复制到临时目录--> <target name="copy" depends="init"> <!--将源项目web目录复制到build的web目录--> <copy todir="${build.web}"> <fileset dir="${project.web}"> <include name="**/*" /> </fileset> </copy> <!--将配置文件复制到build目录--> <copy todir="${build.web.classess}"> <fileset dir="${src.config}"> <include name="**/*"/> </fileset> </copy> <!--将配置文件复制到build目录--> <copy todir="${build.web.classes}"> <fileset dir="${project.lib}" > <include name="**/*.jar"/> </fileset> </copy> <!--将源项目lib目录复制到build的lib目录--> <copy todir="${build.web.lib}" flatten="true"> <fileset dir="${project.lib}" > <include name="**/*.jar"/> </fileset> </copy> </target> <!--编译源项目输出class到build的 class目录--> <target name="compile" depends="copy"> <javac srcdir="${project.src}" destdir="${build.web.classess}" debug="true" includeantruntime="on" encoding="utf-8"> <classpath refid="jar.path"/> </javac> </target> <!--打包--> <target name="package" depends="compile"> <war basedir="${build.web}" destfile="${war}"> <filename name="**/*" /> </war> </target> <!--清理不要的文件--> <target name="clean" depends="package"> <delete dir="${build}" failonerror="false"/> </target> </project>?