ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Andrew.Beac...@nokia.com>
Subject RE: Versioning
Date Tue, 28 May 2002 13:39:44 GMT
Brian,

> 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.properties *****

build.version.major=0
build.version.minor=1
build.number=0345

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

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

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

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

        <!-- create the version number property -->
        <property name="build.version"
                  value="${build.version.major}.${build.version.minor}.${build.number}"/>
    </target>

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

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

${build.version.major}.${build.version.minor}.${build.number}

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!

Andy.

--
Andrew Beacock
Principal Software Engineer/Project Lead
Nokia
NMP/MSW/SSP/AG

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message