You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Stuart Barlow <sb...@peopledoc.com> on 2000/07/20 15:06:11 UTC

incrementing a build number

What is the best way in ant to read in a build number from a file and
increment it by one?

And maybe to write that number back out to the file again?

Do I need to write my own task?


Thanks
---------------------------------------------------------------------------
Stuart Barlow
+44 131 468 8205

Re: incrementing a build number

Posted by Jeff Turner <je...@socialchange.net.au>.
Stuart Barlow wrote:
> 
> What is the best way in ant to read in a build number from a file and
> increment it by one?
> 
> And maybe to write that number back out to the file again?

It would certainly be nice.

I've been using a shell script called from build.sh, invoking Ant with
the parameter -Dbuild=`incBuild.sh`.


#!/bin/sh
# incBuild.sh

[ ! -e BUILD_STAMP ] && touch BUILD_STAMP
x=`cat BUILD_STAMP`
[ "$x" = "" ] && x=1
x=`expr $x + 1`
echo $x > BUILD_STAMP
echo $x


--Jeff

> Do I need to write my own task?
> 
> Thanks
> ---------------------------------------------------------------------------
> Stuart Barlow
> +44 131 468 8205

Re: incrementing a build number

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "SB" == Stuart Barlow <sb...@peopledoc.com> writes:

 SB> Do I need to write my own task?

I'm afraid yes, but I might be wrong.

Reading the number from a file is simple (use the file attribute of
<property>). Creating a new property with the incremented number could
be done using a script task - though I haven't tried it. But I don't
see how you could write this number back into the file you've read the
original number from.

Using a replace task could be the solution for that - probably using
scripting again.

Stefan