How to increment build number in Ant

The corresponding magic all-answering Ant man page tells that you can increment the build number using the
directive. If you insert this directive directly after the opening project tag of your build.xml file, the build number will be increased, every time any of the targets in build.xml are executed. In this way you can increment e.g. the minor version of your build and have not to write a custom extra task.

You can also specify a custom "build.number" file with
<buildnumber file="my.build.number"/>
You can also limit the scope of the buildnumber directive by putting it only into a specific target.