ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject RE: Format of Ant's version string ?
Date Mon, 19 Apr 2004 05:45:15 GMT
The property ant.version contains the buildnumber and the compile-date.
I´d written a snippet for storing the individual infos as properties:

<project name="common-define-checkAnt">
    <scriptdef name="checkAnt" language="javascript">
        <![CDATA[
            importClass(java.text.SimpleDateFormat);
            importClass(java.util.Locale);

            // String evaluation of 'ant.version' string
            // e.g: 'Apache Ant version 1.6beta3 compiled on December 5
2003'
            string   = project.getProperty("ant.version");
            version  = string.substring(string.indexOf("Ant version")+12,
string.indexOf("compiled on")-1);
            compiled = string.substring(string.indexOf("compiled on")+12);

            // Get the compiled date: 'December 5 2003'
            dateParser = new SimpleDateFormat("MMM d yyyy", Locale.US);
            compiledDate = dateParser.parse(compiled);

            compiledYear  = (new
SimpleDateFormat("yyyy")).format(compiledDate);
            compiledMonth = (new SimpleDateFormat("M")
).format(compiledDate);
            compiledDay   = (new SimpleDateFormat("d")
).format(compiledDate);

            project.setNewProperty("ant.version.number", version);
            project.setNewProperty("ant.version.compiled", compiled);
            project.setNewProperty("ant.version.compiled.year",
compiledYear);
            project.setNewProperty("ant.version.compiled.month",
compiledMonth);
            project.setNewProperty("ant.version.compiled.day", compiledDay);
        ]]>
    </scriptdef>
</project>


<project>
  <import file="define-checkAnt.xml"/>
  <checkAnt/>
  <echoproperties prefix="ant.version"/>
</project>


Jan


> -----Original Message-----
> From: Rich Wagner [mailto:richmwagner@hotmail.com]
> Sent: Sunday, April 18, 2004 9:07 PM
> To: user@ant.apache.org
> Cc: richmwagner@hotmail.com
> Subject: Format of Ant's version string ?
> 
> 
> I've written a simple utility to find the "version.txt" file in the 
> "ant.jar" of a given Ant installation, and the utility looks for the:
> 
>     VERSION=<something>
> 
> line in the "version.txt" file.  So far, I know that 
> "<something>" can be of 
> the forms:
> 
>     x.y
>     x.y.z
> 
> where "x", "y" and "z" are integers.  For instance, I've seen 
> "1.5" and 
> "1.6.1", among others.
> 
> However, are there other possibilities I'm not aware of ?  
> For instance, for 
> beta releases (which I've never downloaded personally), is the string 
> something like "x.y.z beta" ?
> 
> Or could there be other variations, like "1.6.1a" ?
> 
> Please let me know, so that I can have confidence that my 
> version string 
> finder/parser is coded correctly...
> 
> Thanks in advance,
> Rich Wagner
> 
> _________________________________________________________________
> Free up your inbox with MSN Hotmail Extra Storage! Multiple 
> plans available. 
> http://join.msn.com/?pgmarket=en-us&page=hotmail/es2&ST=1/go/o
nm00200362ave/direct/01/


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message