技术开发 频道

实战每晚构建之设计和实现

    3.4 类BuildAdmin

    <project name="BuildAdminSystem" default="execute" basedir="." >

    
<!-- 定义方法 -->

    
<target name="init" >

    
<!-- 继承BuildInfoLog -->

    
<property file="BuildInfoLog.properties"/>

    
<property name="cvsroot" value=":pserver:anonymous@10.1.36.135:/data/src" />

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

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

    
<property name="AJPPORT" value="9887" />

    
<property name="HTTPPORT" value="9888" />

    
<property name="HTTPSPORT" value="9889" />

    
<property name="statcvs.jar"

    location
="${lib.dir}/statcvs-0.1.3.jar"/>

    
<taskdef name="statcvs" classname="net.sf.statcvs.ant.StatCvsTask">

    
<classpath>

    
<pathelement path="${statcvs.jar}"/>

    
</classpath>

    
</taskdef>

    
</target>

    
<target name="execute" >

    
<!-- you can add another module here -->

    
<antcall target="build_One_Module">

    
<param name="module" value="nightlybuild"/>

    
</antcall>

    
<!-- you can add another module here -->

    
<!--

    
<antcall target="build_One_Module">

    
<param name="module" value="testcvs"/>

    
</antcall>

    
-->

    
</target>

    
<!-- 方法调用之一depends -->

    
<target name="build_One_Module" depends="init">

    
<!-- 方法调用之一antcall -->

    
<antcall target="cvs_Check_Out">

    
<!-- the CVS module name which includes a build.xml itself -->

    
<!-- 传递参数 -->

    
<param name="module" value="${module}"/>

    
</antcall>

    
<!-- 生成构建标签 -->

    
<property name="nightly_Build_Tag" value="${module}-${tagTime}" />

    
<echo>

    ###############################################

    BuildAdmin.xml:target build_One_Module:

    nightly_Build_Tag is set to ${nightly_Build_Tag}

    ###############################################

    
</echo>

    
<echo>

    ###############################################

    BuildAdmin.xml:target build_One_Module:

    append ${nightly_Build_Tag} to file

    ${webAppDir}
/${nightlyWebAppName}/${nightly_Build_Tags}

    ###############################################

    
</echo>

    
<!-- 记录构建标签 -->

    
<echo append="true" file="${webAppDir}/${nightlyWebAppName}/${nightly_Build_Tags}" >

    ${nightly_Build_Tag}

    
</echo>

    
<!-- 生成项目度量信息 -->

    
<antcall target="statCVS">

    
<param name="module" value="${module}"/>

    
<param name="build_tag" value="${nightly_Build_Tag}" />

    
</antcall>

    
<echo>

    ###############################################

    BuildAdmin.xml:target build_One_Module:

    the software is checked out in ${buildtemp.dir}
/tmp/${module}

    let′s begin to build it and the output will be put into

    ${webAppDir}${nightlyWebAppName}
/${projectLogTopDir}/${nightly_Build_Tag}.txt

    ###############################################

    
</echo>

    
<ant dir="${buildtemp.dir}/tmp/${module}"

    target
="execute"

    inheritAll
="false"

    output
="${webAppDir}${nightlyWebAppName}/${projectLogTopDir}/${nightly_Build_Tag}.txt" >

    
<property name="nightly_Build_Tag" value="${nightly_Build_Tag}" />

    
<property name="AJPPORT" value="${AJPPORT}" />

    
<property name="HTTPPORT" value="${HTTPPORT}" />

    
<property name="HTTPSPORT" value="${HTTPSPORT}" />

    
</ant>

    
<!--

    
<ant dir="../work_nightlybuild"

    antfile
="ProjectBuild.xml"

    target
="execute"

    inheritAll
="false"

    output
="${webAppDir}${nightlyWebAppName}/${projectLogTopDir}/${nightly_Build_Tag}.txt" >

    
<property name="nightly_Build_Tag" value="${nightly_Build_Tag}" />

    
<property name="AJPPORT" value="${AJPPORT}" />

    
<property name="HTTPPORT" value="${HTTPPORT}" />

    
<property name="HTTPSPORT" value="${HTTPSPORT}" />

    
</ant>

    
-->

    
</target>

    
<target name="cvs_Check_Out" >

    
<!-- cvs checkout -->

    
<echo>

    ###############################################

    BuildAdmin.xml:target cvs_Check_Out:

    the software will be checked out in ${buildtemp.dir}
/tmp/${module}

    ###############################################

    
</echo>

    
<delete dir="${buildtemp.dir}/tmp/${module}" />

    
<mkdir dir="${buildtemp.dir}/tmp"/>

    
<cvs cvsRoot="${cvsroot}"

    
package="${module}"

    dest
="${buildtemp.dir}/tmp"

    
/>

    
<cvs dest="${buildtemp.dir}/tmp/${module}" command="log" output="${buildtemp.dir}/tmp/${module}/cvs.log"/>

    
</target>

    
<!-- 生成项目度量信息 -->

    
<target name="statCVS" depends="init" >

    
<echo>

    ###############################################

    BuildAdmin.xml:target statCVS:

    the software will be measureed in ${webAppDir}${nightlyWebAppName}
/${statCVSTopDir}/${build_tag}

    ###############################################

    
</echo>

    
<delete dir="${webAppDir}${nightlyWebAppName}/${statCVSTopDir}/${build_tag}" />

    
<mkdir dir="${webAppDir}${nightlyWebAppName}/${statCVSTopDir}/${build_tag}"/>

    
<statcvs

    projectName
="${module}"

    projectDirectory
="${buildtemp.dir}/tmp/${module}"

    cvsLogFile
="${buildtemp.dir}/tmp/${location}/cvs.log"

    outputDirectory
="${webAppDir}${nightlyWebAppName}/${statCVSTopDir}/${build_tag}"

    
/>

    
</target>

    
</project>
0
相关文章