上个项目中写的Ant build文件

王朝java/jsp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

一、上一个项目中写的,可以编译、自动化测试、打包的build.xml

<?xml version="1.0"?>

<project name="SimulatorEL" basedir="." default="all">

<!-- edit by YangHuaWei -->

<property name="build.dir" value="classes"/>

<property name="lib.dir" value="lib"/>

<property name="dist.dir" value="dist"/>

<property name="source.dir" value="./SimulatorEL/src"/>

<property name="testSrc.dir" value="./SimulatorEL/test"/>

<property name="report.dir" value="report" />

<property name="report_html.dir" value="${report.dir}/html" />

<property name="cvs.repository" value=":pserver:yanghw:cvs@localhost:/usr/local/cvsroot"/>

<property name="cvs.package" value="SimulatorEL"/>

<property name="common.src" value="Common"/>

<property name="common.class" value="CommonClass"/>

<property name="release_AP.dir" value="SimAP/SimulatorEL/AP"/>

<path id="project.classpath">

<fileset dir="${lib.dir}">

<include name="**/*.jar"/>

</fileset>

<pathelement path="${build.dir}"/>

</path>

<target name="init" description="Prepare for build">

<mkdir dir="${build.dir}"/>

<mkdir dir="${dist.dir}"/>

<!--mkdir dir="${logdir}"/-->

<!--mkdir dir="${report.dir}"/-->

<mkdir dir="${report_html.dir}"/>

</target>

<target name="clean" description="Clean all build products">

<delete dir="${build.dir}" quiet="true"/>

<delete dir="${dist.dir}" quiet="true"/>

<delete dir="SimulatorEL" quiet="true"/>

<delete dir="${report.dir}" quiet="true"/>

<delete dir="${common.class}" quiet="true"/>

</target>

<target name="compile" depends="init,checkout,common_build" description="Compile application">

<javac srcdir="${source.dir}" destdir="${build.dir}" encoding="EUC-JP"

includes="**/*.java" debug="on" deprecation="on">

<classpath refid="project.classpath"/>

</javac>

</target>

<target name="compile_test" depends="compile" description="compile the classes of test">

<javac srcdir="${testSrc.dir}" destdir="${build.dir}" encoding="EUC-JP"

includes="**/*.java" debug="on" deprecation="on">

<classpath refid="project.classpath"/>

</javac>

</target>

<target name="test" depends="compile_test" description="Run unit tests">

<!--delete dir="${junit.results}"/>

<mkdir dir="${junit.results}"/-->

<tstamp/>

<junit fork="yes" haltonfailure="no">

<jvmarg value="-Duser.dir=/home/docomo/simBuild/SimulatorEL"/>

<classpath refid="project.classpath"/>

<formatter type="xml" usefile="true"/>

<!--formatter type="xml"/-->

<batchtest todir="${report.dir}">

<fileset dir="${build.dir}" includes="**/*Test.class"/>

</batchtest>

</junit>

<junitreport todir="${report.dir}">

<fileset dir="${report.dir}">

<include name="TEST-*.xml" />

</fileset>

<report format="frames" todir="${report_html.dir}" />

</junitreport>

<jar jarfile="${report.dir}/SimulatorELTestReport-${DSTAMP}-${TSTAMP}.zip" basedir="${report_html.dir}"/>

</target>

<target name="mail" depends="test">

<mail mailhost="192.168.98.1" subject="Test report">

<from address="yanghw@sz.cathay.jp"/>

<to address="docomo-dev@sz.cathay.jp"/>

<message>The nightly build/test has completed</message>

<fileset dir="${report.dir}">

<include name="*.zip"/>

</fileset>

</mail>

</target>

<target name="common_build" description="Build common module">

<!-- checkout common module from cvs -->

<delete dir="${common.src}" quiet="true"/>

<cvs cvsroot="${cvs.repository}" package="Common" dest="."/>

<!-- compile and jar the common module -->

<mkdir dir="${common.class}"/>

<javac srcdir="${cttcommsrc}" destdir="${common.class}" excludes="**/*Test.java" encoding="EUC-JP">

<classpath refid="project.classpath"/>

</javac>

<delete file="${lib.dir}/common.jar" quiet="true"/>

<jar jarfile="${lib.dir}/common.jar" basedir="${common.class}"/>

</target>

<target name="tar" depends="compile,jar" description="Creates a tar archive">

<delete dir="SimAP" quiet="true"/>

<mkdir dir="${release_AP.dir}/src"/>

<mkdir dir="${release_AP.dir}/conf"/>

<mkdir dir="${release_AP.dir}/lib"/>

<!--mkdir dir="SimAP/SimulatorEL/AP/conf"/-->

<copydir src="${source.dir}" dest="${release_AP.dir}/src" includes="**/*.java"/>

<copydir src="SimulatorEL/config/SimulatorEL/AP/conf" dest="${release_AP.dir}/conf"/>

<!--copydir src="SimulatorEL/images" dest="SimAP/SimulatorEL/AP/conf/images"/-->

<copy file="${dist.dir}/SimulatorEL.jar" todir="${release_AP.dir}/lib"/>

<copy todir="${release_AP.dir}/lib">

<fileset dir="${lib.dir}">

<include name="emsutil.jar"/>

<include name="common.jar"/>

</fileset>

</copy>

<tar tarfile="${dist.dir}/SimulatorEL.tar" basedir="SimAP"/>

<gzip zipfile="${dist.dir}/SimulatorEL.tar.gz" src="${dist.dir}/SimulatorEL.tar"/>

</target>

<target name="jar">

<jar jarfile="${dist.dir}/SimulatorEL.jar">

<fileset dir="${build.dir}">

<exclude name="**/*Test*"/>

</fileset>

</jar>

</target>

<target name="checkout" description="Update package from CVS">

<cvs cvsroot="${cvs.repository}" package="${cvs.package}" dest="."/>

</target>

<target name="all" depends="clean,mail,tar" description="Build application"/>

</project>

二、在Linux下写一个shell文件autoTest.sh

cd ~/build

source ~/.docomo.profile

ant mail

三、加入到crontab中,每天自动运行

# crontab -e

4 9 * * * /home/docomo/build/autoTest.sh

crontab的使用参见收藏的文章

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航