web应用开发简单的ANT构建文件

知行天下 2013-10-15

<projectname="first_spring_ws"basedir="."default="junit">

<propertyname="tomcat.lib"value="E:/Tomcat6.0/lib"/>

<propertyname="src"value="${basedir}/src"/>

<propertyname="build"value="${basedir}/build"/>

<propertyname="webRoot"value="${basedir}/WebRoot"/>

<propertyname="lib"value="${webRoot}/WEB-INF/lib"/>

<propertyname="build.class"value="${build}/classes"/>

<propertyname="project.name"value="first_spring_ws"/>

<propertyname="test.src"value="${basedir}/test"/>

<propertyname="test.report"value="${basedir}/report"/>

<pathid="class_path">

<filesetdir="${tomcat.lib}">

<includename="**.jar"/>

</fileset>

<filesetdir="${lib}">

<includename="**.jar"/>

</fileset>

</path>

<targetname="clean"description="删除目录">

<echomessage="删除目录"></echo>

<deletedir="${build}"></delete>

<deletedir="${test.report}"/>

</target>

<targetname="init"description="创建目录"depends="clean">

<echomessage="创建目录-执行"></echo>

<mkdirdir="${build.class}"/>

<mkdirdir="${test.report}"/>

<mkdirdir="${test.report}/framework-${DSTAMP}-${TSTAMP}"/>

</target>

<targetname="compile"description="编译文件"depends="init">

<echomessage="编译文件"></echo>

<javacsrcdir="${src}"destdir="${build.class}">

<classpathrefid="class_path"/>

<compilerargline="-encodingGBK"/>

</javac>

<copytodir="${build.class}">

<filesetdir="${src}">

<includename="*.xml"/>

<includename="*.properties"/>

</fileset>

</copy>

<javacsrcdir="${test.src}"destdir="${build.class}">

<classpathrefid="class_path"/>

<compilerargline="-encodingGBK"/>

</javac>

</target>

<targetname="war"depends="compile">

<echomessage="打成war包"></echo>

<wardestfile="${build}/${project.name}.war"webxml="${webRoot}/WEB-INF/web.xml">

<filesetdir="${webRoot}"/>

<libdir="${lib}"/>

<classesdir="${build.class}"/>

</war>

</target>

<pathid="junit_path">

<pathrefid="class_path"></path>

<pathelementlocation="${build.class}"/>

</path>

<targetname="junit"depends="compile">

<echomessage="单元测试"></echo>

<junitprintsummary="true">

<classpathrefid="junit_path">

</classpath>

<formattertype="plain"/>

<batchtestfork="yes"todir="${test.report}/framework-${DSTAMP}-${TSTAMP}">

<filesetdir="${test.src}">

<includename="**/*Driver.java"/>

</fileset>

</batchtest>

</junit>

</target>

</project>

相关推荐