Simple ANT build files for web application development

<project name="first_spring_ws" basedir="." default="junit">

<property name="tomcat.lib" value="E:/Tomcat 6.0/lib" />
<property name="src" value="${basedir}/src" />
<property name="build" value="${basedir}/build" />
<property name="webRoot" value="${basedir}/WebRoot" />
<property name="lib" value="${webRoot}/WEB-INF/lib" />
<property name="build.class" value="${build}/classes" />
<property name="project.name" value="first_spring_ws" />
<property name="test.src" value="${basedir}/test" />
<property name="test.report" value="${basedir}/report" />

<path id="class_path">
<fileset dir="${tomcat.lib}">
<include name="**.jar"/>
</fileset>
<fileset dir="${lib}">
<include name="**.jar" />
</fileset>
   </path>


<target name="clean" description="删除目录">
<echo message="删除目录"></echo>
<delete dir="${build}"></delete>
<delete dir="${test.report}"/>
</target>

<target name="init" description="创建目录" depends="clean">
<echo message="创建目录-执行"></echo>
<mkdir dir="${build.class}"/>
<mkdir dir="${test.report}"/>
<mkdir dir="${test.report}/framework-${DSTAMP}-${TSTAMP}"/>

</target>

<target name="compile" description="编译文件" depends="init">
<echo message="编译文件"></echo>
<javac srcdir="${src}" destdir="${build.class}">
<classpath refid="class_path" />
<compilerarg line="-encoding GBK"/>

</javac>

<copy todir="${build.class}">
<fileset dir="${src}">
<include name="*.xml"/>
<include name="*.properties"/>
</fileset>
</copy>

<javac srcdir="${test.src}" destdir="${build.class}">
<classpath refid="class_path" />
<compilerarg line="-encoding GBK"/>
</javac>
</target>

<target name="war" depends="compile">
<echo message="打成war包"></echo>
<war destfile="${build}/${project.name}.war" webxml="${webRoot}/WEB-INF/web.xml">
<fileset dir="${webRoot}" />
<lib dir="${lib}" />
<classes dir="${build.class}" />
</war>
</target>

<path id="junit_path" >
<path refid="class_path"></path>
<pathelement location="${build.class}"/>

</path>

<target name="junit" depends="compile">

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

<junit printsummary="true">

<classpath refid="junit_path">
</classpath>

<formatter type="plain"/>

<batchtest fork="yes" todir="${test.report}/framework-${DSTAMP}-${TSTAMP}">
<fileset dir="${test.src}">
<include name="**/*Driver.java"/>
</fileset>
</batchtest>
</junit>

</target>
</project>

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326767981&siteId=291194637
Recommended