ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Donie <sdo...@zycor.lgc.com>
Subject RE: [Cruisecontrol-user] how to ?
Date Fri, 27 Apr 2001 15:41:01 GMT
I have been using a pre-release version of CC, so things may be a bit
different for y'all, but here is what I have in my setup. I have simplified
it a lot, but it should show what's needed. 

First, I have a directory structure like this:
${basedir}
	logs
	src
	tools
	classes
	jar

etc.

The build.xml, masterbuild.properties, and masterbuild.bat files are in the
tools directory. On the build machine, the base directory is
d:\TahoeBuild\tahoe, so you'll see that hard-coded into the .properties
file. I am using a custom label incrementer that is based on the date. On
the build machine, I have set things up so there is a scheduled task every
night at midnight that just runs "Ant allclean". This is so that the whole
team gets build mail daily (to keep everyone confident that everything is
working). 

Benoit's questions have been about the logfiles directory, and about the
property ${lastgoodbuildtime}. 

The logfiles directory is where modificationset.xml, and build.xml (the
build log) are written - I also have my junit output writing to the same
place. Note that in the TARGET where the modificationset task is running,
you should set a property ${modificationset.file} so that the task knows
where to write the file. 

lastgoodbuildtime is initially set (the very first time you run CC) with the
command-line flag. After that, it is updated automatically while CC
continues to run. If you need to stop the CC process, then it should usually
be read from the buildcycleinfo file. I have a batch file I use to set the
classpath, then run CC, and I have set it up so I can:
 - give it 2 arguments for lastgoodbuildtime and label
 - give it no arguments, in which case it uses a lastgoodbuildtime of today
at midnight, and a label based on today's date
 - give it an argument "restart", which causes the build info to be read
from the buildcyleinfo file

Hope this is helpful.

Steve

========= build.xml =============
<project name="Tahoe" default="build" basedir="..">
  
  <!-- set global properties for this build -->
  <!-- first, names of directories that are used -->
  <property name="masterbuild.logdir" value="logs" />
  <property name="src" value="src" />
  <property name="jar" value="jar" />
  <property name="bin" value="bin" />
  <property name="javadocs" value="javadocs" />
  <property name="tools" value="tools" />
  <property name="classes" value="classes" />
  <property name="build" value="build" />
  <property name="dist"  value="dist" />
  <property name="scripts"  value="scripts" />

  <!-- this is the name of the file generated (if above is true) when
running the JUnit target -->
  <property name="JUnit.OutputFile" value="TestAllResults" />
  <property name="JUnit.XMLFileName" value="logs/${JUnit.OutputFile}.xml" />

<!-- ----- 'meta' targets ----- -->
  <target name="allclean" depends="clean,all" description="Builds everything
clean"/>
  <target name="all" depends="init,version,junit,dist" description="Builds
everything, not clean"/>
  <target name="build" depends="init,version,compile,junit"
description="Runs compile and JUnit - default target"/>
  <target name="rebuild" depends="clean,build" description="Runs clean,
compile and JUnit"/>

  <target name="masterbuild" depends="modificationset,cleanclasses,all"
description="Build used for masterbuild." />
  <target name="masterclean" depends="modificationset,allclean"
description="Build used for masterbuild, clean." />

<!-- ----- targets ----- -->
  <target name="modificationset">
    <property name="modificationset.file" value="logs/modificationset.xml"
/>
    <modificationset lastbuild="${lastGoodBuildTime}" 
                     quietperiod="300" 
                     dateformat="yy-MM-dd hh:mm:ss a z" 
                     emailsuffix="@lgc.com">
      <cvselement localworkingcopy="."
cvsroot=":pserver:renobuild@boson.lgc.com:/net/houfiler02/vol/vol2/cvs/tahoe
" />
    </modificationset>
  </target>  

  <target name="init">
    <!-- Create the time stamp -->
    <tstamp>
    	<format property="TIME_NOW" pattern="hh:mm:ss a z" />
    </tstamp>
    <tstamp/>
    <echo message="Building ${ant.project.name} on ${Machine} in ${basedir}
starting at ${TIME_NOW} on ${TODAY}" />
    <echo file="header.log">Building ${ant.project.name} on ${Machine} in
${basedir} starting at ${TIME_NOW} on ${TODAY}
    </echo>
  </target>
  
</project>

================ masterbuild.bat ======================
@echo off
title MasterBuild

echo Starting MasterBuild:
date /t
time /t
echo.
set ANT_HOME=%DS_HOME%\tools\ant
SET
CLASSPATH=%DS_HOME%\tools\ant\lib\masterbuild.jar;%DS_HOME%\tools\ant\lib\an
t.jar;%DS_HOME%\tools\ant\lib\optional.jar;%DS_HOME%\tools\ant\lib\jaxp.jar;
%DS_HOME%\tools\ant\lib\parser.jar;%DS_HOME%\jar\junit.jar;%JAVA_HOME%\lib\t
ools.jar;%JAVA_HOME%\lib\classes.zip;%DS_HOME%\tools\ant\lib\activation.jar;
%DS_HOME%\tools\ant\lib\mail.jar;%DS_HOME%\tools\ant

REM this sets the MasterBuildLabel and MasterBuildTime based on todays date
call %DS_HOME%\tools\SetMasterBuildData.bat

if .%1.==.restart. goto RESTART

if NOT .%1.==.. set MasterBuildTime=%1
if NOT .%2.==.. set MasterBuildLabel=%2

if not defined MasterBuildTime echo MasterBuildTime not defined&goto :EOF
if not defined MasterBuildLabel echo MasterBuildLabel not defined&goto :EOF

echo MasterBuildTime  %MasterBuildTime%
echo MasterBuildLabel %MasterBuildLabel%
echo.
echo use MasterBuild.bat restart to re-start MasterBuild.
tools\choice /T:Y,30 Ready to start? (starts automatically in 30 seconds) 
if errorlevel 2 goto :EOF

java -DDS_HOME=%DS_HOME% -DMachine=%COMPUTERNAME%
org.apache.tools.ant.MasterBuild -lastbuild %MasterBuildTime% -label
%MasterBuildLabel% -properties %DS_HOME%\tools\masterbuild.properties 
goto :EOF

:RESTART
echo restarting, using buildcycleinfo
REM this just uses the file buildcycleinfo to read in the last good build
time and label
java -DDS_HOME=%DS_HOME% -DMachine=%COMPUTERNAME%
org.apache.tools.ant.MasterBuild -properties
%DS_HOME%\tools\masterbuild.properties 


====================== SetMasterBuildData.bat ===================
@echo off
REM How this works:
REM first FOR command splits the output of the date /t command which looks
like Tue 02/06/2001 into
REM 2 tokens: 1="Tue", 2="02/06/2001".
REM Then the second FOR command splits the 2nd token (%%j) into 3 tokens:
1="02", 2="06", 3="2001"
REM Finally, the Year, month, and day are set based on those tokens.

for /F "tokens=1,2,*" %%i in ('date /T') do for /F "tokens=1,2,3,* delims=/"
%%s in ("%%j") do set MBMonth=%%s&set MBDay=%%t&set MBYear=%%u

set MasterBuildLabel=%MBMonth%%MBDay%.1
set MasterBuildTime=%MBYear%%MBMonth%%MBDay%000100

================ masterbuild.properties =====================

# file that contains the time that the current build started.  this will be
picked up by the servlet to display that a build is
# currently running/not running
currentBuildStatusFile = d:\\TahoeBuild\\tahoe\\logs\\currentbuild.txt

# directory where logs should be created.
logdir=d:\\TahoeBuild\\tahoe\\logs

# ant file to execute
antfile = tools/build.xml

# target that the ant file should run.  maybe should just be the default
target of the project and not specified here?
target = masterbuild

# clean target (should also include building, but just unconditionally clean
first) this is the target that will be run every n builds,
# so that we can ensure that we have no integration issues, but generally
keep build times down.
# NOTE: Because the nightly build does a clean, masterbuild does not.
cleantarget = masterclean

# comma delimited list of ant property names that refer to files to be
merged 
# into the xml specified by the ant property XmlLogger.file
auxlogfiles = modificationset.file,JUnit.XMLFileName

# multiple to force a clean build
cleanBuildEvery = 99

# Label Incrementer 
labelIncrementerClass=TahoeLabelIncrementer


Mime
View raw message