ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject RE: Versioning
Date Tue, 28 May 2002 13:39:44 GMT

> So it *does* work for numeric properties.  Hmmm...  It 
> doesn't look like it can do anything for rolling, but I think 
> I can do that with conditions and the like.  I'll give it a 
> shot.  Thanks!

Here's what works for me, (not using Ant 1.5Beta1 though due to bug in <propertyfle>...
;) )

I have the major, minor, and build numbers separately stored in the 
property file, and I increment the build number when I compile, but only 
then.  That way I can package, test, or JavaDoc as many times as I like 
and it doesn't change the build number (so I always know what compiled 
code is there).

I've included the relevant sections below:

***** *****


***** build.xml *****

    <!-- 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"/>

    <!-- init -->
    <target name="init"
            description="build initialization">
        <!-- make the file variables available -->
        <property file=""/>

        <!-- create the version number property -->
        <property name="build.version"

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

The whole version number is loaded into the ${build.version} property, but you 
can also get the separate parts as well:


Good luck! (and let me know when you get it working with the new version 
of Ant.  I would use the buildnumber task but if I remember correctly (
from reading the doc) it loads the property in from the file, and then 
updates the file.

So the value on disk is actually the next build to happen rather than 
the current build.  That means that I wouldn't be able to query the 
build file on disk to see what the last build was!


Andrew Beacock
Principal Software Engineer/Project Lead

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

View raw message