刚才写了一个日构建脚本,还没有写完,还差界面冒烟测试、把构建结果通知相关开发人员这个功能没有实现,太晚了,明天再搞:
<?xml version="1.0" encoding="GB2312" ?>
<project name="dailybuild" default="main">
<!--tomcat的路径-->
<property name="tomcathome.dir"
value="C:\Program Files\Apache Software Foundation\Tomcat 5.0\"/>
<property name="tomcathome.mgr.dir"
value="http://127.0.0.1:8080/manager/"/>
<property name="tomcat.username"
value="admin"/>
<property name="tomcat.password"
value=""/>
<property name="cownewwebpath"
value="/CownewPISWeb"/>
<!--Web应用的路径-->
<property name="cownewwebhome.dir"
value="${tomcathome.dir}webapps\CownewPISWeb\"/>
<!--Web应用的源码路径(主要供稍后的编译用)-->
<property name="cownewwebhome.java.dir"
value="${cownewwebhome.dir}WEB-INF\java\"/>
<!--Web应用输出的class路径-->
<property name="cownewwebhome.classes.dir"
value="${cownewwebhome.dir}WEB-INF\classes\"/>
<!--CVS根路径-->
<property name="cvsRoot"
value=":pserver:杨中科:123456@192.168.1.6:/cvsrep"/>
<property name="cvs.outtemp.dir"
value="${cownewwebhome.dir}cvsout/"/>
<taskdef name="stopTomcat" classname="org.apache.catalina.ant.StopTask">
<classpath>
<path location="${tomcathome.dir}/server/lib/catalina-ant.jar"/>
</classpath>
</taskdef>
<taskdef name="startTomcat" classname="org.apache.catalina.ant.StartTask">
<classpath>
<path location="${tomcathome.dir}/server/lib/catalina-ant.jar"/>
</classpath>
</taskdef>
<target name="main">
<echo>停止Tomcat</echo>
<stopTomcat url="${tomcathome.mgr.dir}" username="${tomcat.username}"
password="${tomcat.password}" path="${cownewwebpath}"/>
<echo>清除原有构建文件</echo>
<delete dir="${cownewwebhome.dir}"/>
<echo>开始从CVS下拉代码</echo>
<mkdir dir="${cvs.outtemp.dir}"/>
<cvs cvsRoot="${cvsRoot}" package="CownewPISWeb" dest="${cvs.outtemp.dir}"/>
<mkdir dir="${cownewwebhome.dir}"/>
<copy todir="${cownewwebhome.dir}">
<fileset dir="${cvs.outtemp.dir}CownewPISWeb/WebContent/"/>
</copy>
<mkdir dir="${cownewwebhome.java.dir}"/>
<copy todir="${cownewwebhome.java.dir}">
<fileset dir="${cvs.outtemp.dir}CownewPISWeb/src/"/>
</copy>
<delete dir="${cvs.outtemp.dir}"/>
<echo>开始编译源代码</echo>
<mkdir dir="${cownewwebhome.classes.dir}"/>
<javac srcdir="${cownewwebhome.java.dir}" destdir="${cownewwebhome.classes.dir}" >
<classpath>
<pathelement location="E:\保留文档\java\常用包\junit-3.8.1.jar" />
</classpath>
</javac>
<delete dir="${cownewwebhome.java.dir}"/>
<echo>启动Tomcat</echo>
<startTomcat url="${tomcathome.mgr.dir}" username="${tomcat.username}"
password="${tomcat.password}" path="${cownewwebpath}"/>
<echo>开始冒烟测试</echo>
<junit printsummary="yes" fork="yes" haltonfailure="no">
<classpath>
<pathelement location="E:\保留文档\java\常用包\junit-3.8.1.jar"/>
<pathelement location="${cownewwebhome.classes.dir}"/>
</classpath>
<batchtest fork="yes" todir="${cownewwebhome.classes.dir}" haltonfailure="no">
<fileset dir="${cownewwebhome.classes.dir}">
<include name="**/bvt/*.class" />
</fileset>
</batchtest>
</junit>
<echo>todo:</echo>
</target>
</project>