另一个好的ant文件收藏

<?xml version="1.0" encoding="UTF-8" ?>

<project name="AntTest" default="deploy" basedir=".">

<property name="tomcat_home" value="d:/tomcat6" />
<property name="jdk_home" value="d:/jdk6" />
<property name="webapp.name" value="anttest" />
<property name="build_dir" value="build/classes" />
<property name="webapp.class.dir" value="${basedir}/WebContent/WEB-INF/classes" />
<property name="tomcat_lib" value="${tomcat_home}/lib" />
<property name="webapp_home" value="${tomcat_home}/webapps" />
<property name="jdk_lib" value="${jdk_home}/lib" />
<property name="jdk_bin" value="${jdk_home}/bin" />
<property name="jdk_jre_lib" value="${jdk_home}/jre/lib" />

<target name="clean">
<echo>
Cleaning the pre-built files or directories.
</echo>

<delete dir="${build_dir}" />
<delete dir="${webapp_home}/${webapp.name}.war" />
<delete dir="${webapp.class.dir}" />
<delete file="${basedir}/${webapp.name}.war" />
<delete file="${basedir}/${webapp.name}.jar"/>
<delete dir="${webapp_home}/${webapp.name}" />
</target>

<target name="init_directory">
<mkdir dir="${build_dir}" />
<mkdir dir="${webapp.class.dir}" />
</target>

<target name="init_classpath">
<path id="build.path">
<pathelement location="${jdk_lib}" />
<pathelement location="${jdk_jre_lib}" />
<pathelement location="${ant.library.dir}/junit-4.1.jar"/>
<fileset dir="${tomcat_lib}">
<include name="**/*.jar" />
</fileset>
</path>
</target>

<target name="compile" depends="clean, init_directory, init_classpath">
<echo message="Compile servlet!" />
<javac destdir="${build_dir}" fork="yes" executable="${jdk_bin}/javac" debug="on">
<src path="${basedir}/src" />
<classpath refid="build.path" />
</javac>
</target>

<target name="build_jar" depends="compile">
<jar destfile="${basedir}/${webapp.name}.jar">
<fileset dir="${build_dir}" includes="**/*.class" />
</jar>
</target>

<target name="war" depends="compile">
<copy todir="${webapp.class.dir}">
<fileset dir="${build_dir}" includes="**/*.class" />
</copy>
<war destfile="${basedir}/${webapp.name}.war" update="true" webxml="${basedir}/WebContent/WEB-INF/web.xml">
<classes dir="${webapp.class.dir}" />
<zipfileset dir="${basedir}/WebContent">
<exclude name="**/*.Thumb" />
</zipfileset>
</war>
</target>

<target name="runtests" depends="compile" deion="Run JUnit Test for Project">
<java fork="yes" classname="junit.textui.TestRunner" taskname="junit" failοnerrοr="true">
<arg value="test.servlet.UserUtilTest" />
<classpath>
<pathelement location="${build_dir}" />
<pathelement path="${java.class.path}" />
</classpath>
</java>
</target>

<target name="runtests1" depends="init_classpath" deion="Run Junit tests">
<junit printsummary="yes">
<classpath>
<pathelement location="${build_dir}"/>
</classpath>

<formatter type="plain"/>

<batchtest fork="no" todir="c:/">
<fileset dir="${basedir}/src">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
</target>

<target name="deploy" depends="war">
<copy file="${basedir}/${webapp.name}.war" tofile="${webapp_home}/${webapp.name}.war" />
</target>

<target name="start_tomcat">
<exec executable="${tomcat_home}/bin/startup.bat" />
</target>

<target name="stop_tomcat">
<exec executable="${tomcat_home}/bin/shutdown.bat" />
</target>

</project>

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jackyrongvip/archive/2008/12/30/4607454.aspx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值