I wanted to find some solution to a problem of automatic generation of build numbers/version identifiers using an ANT. I figured out that I can achieve it in the following way:

<target name="numerate.version"
        description="Generates version number and sets it in
                     Client properties file.">
    <tstamp>
        <format property="build.time"
                pattern="yy-MM-dd_hh:mm"
                unit="hour" />
    </tstamp>

    <buildnumber file="build.number" />

    <property name="version.code"
              value="${build.version}/${build.time}/${build.number}" />

    <echo>Version: ${version.code}</echo>

    <replaceregexp file="${client.commonsi18n.pl}"
                   match="(version[ \t]*=[ \t]*)+.*$"
                   byline="true"
                   replace="\1${version.code}" />
</target>

A short description what is going on:

  • tstamp is generating an actual date in given format (yy-MM-dd_hh:mm) and saves it as a property (build.time),
  • buildnumber saves the incremented number of build in a file (build.number),
  • replaceregexp replaces the given expression (version[ \t]*=[ \t]*)+.*$ with a following expression \1${version.code}. In other words – in this example, it replaces the old build/version number with the new one.

The last part (replaceregexp) is used to get the most recent version number in the *.properties file which can be printed on the presentation layer (i.e. on the page footer). You can achieve it using the GWT i18n features, which uses the properties files for international labels generation.

Needles to say, this target should be invoked before the actual GWT compilation.
An example of generated build/version number using this script is as follows:

0.1d/10-01-08_07:51/31