ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nico Seessle" <n...@seessle.de>
Subject Re: javac task filtering
Date Sat, 30 Sep 2000 11:21:20 GMT
----- Original Message -----
From: "Paul Arzul" <patricka@exinet.co.za>
To: <ant-user@jakarta.apache.org>
Sent: Friday, September 29, 2000 12:05 PM
Subject: javac task filtering


> aside: is there version numbering support in ant
> 1.2? something that could read a file, and auto increment a
> build number?
>

No direct support, but you can do something like this as follows:

- Read current value from property-file
- Increment value (or do anything else to them)
- write them back to the property-file
- use them

This example requires the script-task (and therefor BSF (bean scripting
framework) from IBM - last time I looked at there page it seemed to ba
available only by CVS...) and rhino (the Javascript-Engine) from
http://www.mozilla.org

<?xml version="1.0"?>
<project name="myProject" default="default" basedir=".">

    <target name="default">
       <property file="myProject.properties"/>

       <script language="javascript"> <![CDATA[
           var buildNumber = parseInt(myProject.getProperty('buildNumber'));
// get current value
           if (isNaN(buildNumber)) buildNumber = 0;  // if not a number (no
value) initialize to zero
           buildNumber = buildNumber + 1; // Increment by one
           myProject.setProperty('buildNumber', buildNumber); // and put
back
       ]]></script>

       <echo file="myProject.properties">## Automatically generated.
##
## Do not modify!
##
buildNumber=${buildNumber}
       </echo>

       <echo>
          This is Build ${buildNumber}
       </echo>
    </target>

</project>

Nico




Mime
View raw message