Sorry it took so long to respond...
The <buildnumber/> task takes a file and increments the number in the
file. If the file doesn't exist, Ant will create it and put the number
"0" in there.
It is NOT for a complex build number that includes major.minor.micro
numbering. It's simply an integer.
There have been several complaints about this task: The biggest is
that you can't specify the property where the build number is set or
simply read the build number without incrementing it.
There is an OPTIONAL task called <PropertyFile> that is actually not
really an optional task. Unlike most optional tasks, you can use it
without needing any third party jarfiles. It works just like a regular
Ant task. I have no idea why it is considered an optional task.
The <PropertyFile> task may do exactly what you want without any need
for AntContrib tasks. Here's an example build.xml that used both
<buildnumber> and <propertyfile>. It's pretty straight forward.
<project name="test" default="test" basedir=".">
<target name="test">
<!-- Note: This would be your default build task -->
<property file="version.properties"/>
<buildnumber/>
<echo message="Now on build number ${major}.${minor}.${build.number}"/>
</target>
<target name="major"
description="Increments Major">
<propertyfile
file="version.properties"
comment="Versioning file">
<entry key="major"
value="1"
default="1"
type="int"
operation="+"
pattern="00"/>
</propertyfile>
<propertyfile
file="version.properties"
comment="Versioning file">
<entry key="minor"
value="0"
default="0"
type="int"
operation="="
pattern="00"/>
</propertyfile>
<propertyfile
file="build.number"
comment="Build Number">
<entry key="build.number"
value="1"
default="1"
type="int"
operation="="
pattern="0000"/>
</propertyfile>
</target>
<target name="minor"
description="Increments Minor">
<propertyfile
file="version.properties"
comment="Versioning file">
<entry key="minor"
value="1"
default="1"
type="int"
operation="+"
pattern="00"/>
</propertyfile>
<propertyfile
file="build.number"
comment="Build Number">
<entry key="build.number"
value="1"
default="1"
type="int"
operation="="
pattern="0000"/>
</propertyfile>
</target>
</project>
On Fri, May 1, 2009 at 11:31 AM, Eric Fetzer <[email protected]> wrote:
> What is the prescribed method of setting properties in a property file?
> Specifically, I'm speaking of a file that keeps track of one of the build
> numbers. Here's a simple example with what I'd like to do in it:
>
> <target name="main">
> <if>
> <equals arg1="${major.increment}" arg2="true"/>
> <then>
> <buildnumber file="major.number"/>
> <propertycopy name="major.number" from="build.number"/>
> <!--This would be great, but is my imagination, how would it really
> work?-->
> <buildnumber file="minor.number" reset="true"/>
> <propertycopy name="minor.number" from="build.number"/>
> </then>
> <else>
> <property file="major.number"/>
> <propertycopy name="major.number" from="build.number"/>
> <buildnumber file="minor.number"/>
> <propertycopy name="minor.number" from="build.number"/>
> </else>
> </if>
> <property name="full.buildnumber"
> value="${major.number}.${minor.number}"/>
> </target>
>
> Thanks,
> Eric
>
>
>
--
David Weintraub
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]