ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject RE: Build numbers - always available (all targets), sometimes incremented (compile target only)
Date Mon, 11 Feb 2002 14:39:23 GMT

> I'm trying to create a build file that includes a build number.
> The build number should be stored externally.  It should always 
> be loaded with either the most recent build number, or a default 
> value. When the "compile" target is run, the number should be 
> incremented, saved [to disk], and the new value should be available 
> for the rest of the script.  I would like the appropriate build 
> number to be included in the documentation.

I can't answer all your questions but I have done something similar 
with the build number, only increment during compile, but available 
for all tasks.

So this is what I had done...

The build number is stored in an external properties file, and if it 
doesn't exist then the build script will create and store the build 
number in the property file.

Here are the specific targets to show you the details:

    <!-- init.compile -->
    <!-- used by other ant targets, not to be called by the build user -->
    <target name="init.compile"
        <!-- format the current date & time -->
            <format property="time.start" pattern="HH:mm MMMM d, yyyy"/>

        <!-- increment the build number in the -->
        <propertyfile file="">
            <entry key="" type="string" value="${time.start}"/>
            <entry key="build.number" type="int" operation="+" pattern="0000"/>

This target is only called by the compile target, and purely sets the 
date and time (also stored in the properties file) and increments the 
build number, or creates one if it doesn't exist.

    <!-- init -->
    <target name="init"
            description="build initialization">
        <!-- set up the output logs -->
        <record name="build.log" append="no"/>
        <record name="buildVerbose.log" append="no" loglevel="verbose"/>
        <!-- get the current date & time -->

        <!-- make the file variables available -->
        <property file=""/>

This target is called by all other targets, it loads the 
file which contains the build number and date and time that the last compile 
was issued.  It also sets up the logging files.

    <!-- compile -->
    <target name="compile"
            depends="init.compile, init, info"
            description="compile the java">

Calls init.compile and then init (info just prints property info using <echo>

    <!-- javadoc -->
    <target name="javadoc"
            depends="init, info"
            description="generate the JavaDoc">

Calls just init, and so it uses the current build number.

Hope this helps, just try the above and then ask me if you need any more help.

Good luck!


Andrew Beacock
Senior Software Engineer/Project Lead
Nokia Mobile Phones

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message