Answer
Check out Ant's optional <propertyfile> task. It has numeric incrementing capability (as well as string append and date calculation capabilities). By auto-incrementing a number from a properties file, and then reading the properties file using the <property file="..."> task you can easily implement auto-incrementing build numbers.
Is this item
helpful? yes no
Previous votes Yes: 2 No: 0
|
|
Comments and alternative answers
 |
 |
Re: increment build number
K rapp, Dec 4, 2001 [replies:3]
I tried the property file task. But everytime I run the script, it rewrites the properties file and therefore always starts from 0 instead of going onto the next higher number, in this case "1".
Are there any examples on how to increment existing numbers rather than taking current time and date as it is explained in the documentation? Ant would have to be able to read off the properties file first to be able to increment it. Does Ant support this?
Thanks for all your help
Kerstin
Is this item
helpful? yes no
Previous votes Yes: 0 No: 0
|
|

|
 |
 |
 |
 |
Re[3]: increment build number
K rapp, Dec 5, 2001 [replies:1]
I figured it out how to keep it incrementing, rather than overwriting, but for some reason it doesn't resolve the key="build.number" so I can call it later to label the sources in VSS"
I will add the code and error message.
Thanks, Kerstin
Code:
<target name="usage">
<propertyfile file="./build.properties">
<entry key="minor.number" type="int" operation="+" value="1" pattern="00"/>
</propertyfile>
<echo message= "Build ${minor.number}"/>
</target>
error:
[propertyfile] Updating property file: (rather long path to) .....\build.properties
Property ${minor.number} has not been set
[echo] Build ${minor.number}
[echo]
BUILD SUCCESSFUL
Is this item
helpful? yes no
Previous votes Yes: 0 No: 0
|
|

|
 |
 |
 |
 |
 |
Re[4]: increment build number
Erik Hatcher PREMIUM, Dec 5, 2001
<propertyfile> does not load the the file into Ant properties. That is why ${minor.number} is not resolving in the above example. You should load the file with <property file="./build.properties"/>
Is this item
helpful? yes no
Previous votes Yes: 0 No: 0
|
|

|
 |
 |
Re: Can Ant Increment a build number yes it can....
Erik Hatcher PREMIUM, Feb 6, 2002 [replies:3]
That was a lot of effort to do something that you could have done much easier.... you could have written the Java class with @VERSION@ tags and used the <replace> or <copy> task to create a build-time source module that gets compiled instead of the templated one.
Is this item
helpful? yes no
Previous votes Yes: 0 No: 0
|
|

|
 |
Here is a solution I came up with to autogenerate an html file with build # and build date.
Brendan Patterson, Mar 18, 2003 [replies:3]
1) add this target to your build.xml
-----------
<!-- this target will automatically create an html file with
an incremented build number and version number-->
<target name="versionInfo" depends="props" >
<propertyfile
file="version.properties" comment="Build version info">
<entry key="buildDate" type="date" value="now"/>
<entry key="buildNum" default="0" type="int" operation="+" value="1"/>
</propertyfile>
<copy file="${web-source-dir}/version.html" tofile="${build-dir}/version.html" overwrite="true" />
<replace
file="${build-dir}/version.html"
value="value not found in version.properties"
propertyFile="version.properties">
<replacefilter
token="@buildDate@"
property="buildDate"/>
<replacefilter
token="@buildNum@"
property="buildNum"/>
</replace>
</target>
----------
2) put a an html file like this in the right place
to have its values populated by the above target
-----------
- Project - Version - Build # - Build Date
My Proj - 1.0 - @buildNum@ - @buildDate@
-----------
The end result of this is having ANT automatically populate an html file with build version info that can then be referenced by a user of the webapp. Its pretty slick.
Is this item
helpful? yes no
Previous votes Yes: 2 No: 0
|
|

|
 |
 |
Re: Here is a solution I came up with to autogenerate an html file with build # and build date.
Mani Achanta, Sep 1, 2004
Is there anyway that I can add a version automatically to the HTML file (just like @buildNum@ and @buildDate@). The format of the version number should be "2.87.buildnumber".
where, 2 - Major version
87 - Minor version.
By default the "entry key" field in "PropertyFile" task supports only int, date or string. How can i auto-increment the minor/major version only and print it out to the HTML file?
Thanks in Advance!
Mani
Is this item
helpful? yes no
Previous votes Yes: 0 No: 0
|
|

|
|
|
 |
|