For a while I wrote a snippet to check a couple of fix values against the -version string ("Apache Ant version 1.6.1 compiled on February 12 2004") and extracts some information (compile date, version) from that.
... but the last computer crash has stolen that :( (now I wrote a script to backup such things) IMHO it is important that such a condition can check - the current version is equals a needed (<antversion equals="1.6.1"/> ==> 1.6.1) - is newer than a specified one (<antversion newer="1.6.1"/> ==> 1.6.1, 1.6.2B1, 1.6.2, CVSHEAD) Advantages of such a condition - easier provide of a statements like "this script needs Ant up to 1.6 because of the use of <macrodef>" (can be done by a couple of <available> ...) - import a different set of 3rd party libs according the the ant version. 1.6.1 needs other lib versions than 1.4 :) ... mmh - class loader problem? :( Just looked into oata.Main and found the +getAntVersion():String method. You can parse that return statement or more simply use only a part of their implementation (line 864): Properties props = new Properties(); InputStream in = Main.class.getResourceAsStream("/org/apache/tools/ant/version.txt"); props.load(in); in.close(); version = props.getProperty("VERSION"); Jan > -----Ursprüngliche Nachricht----- > Von: Magesh Umasankar [mailto:[EMAIL PROTECTED] > Gesendet am: Freitag, 2. Juli 2004 16:48 > An: [EMAIL PROTECTED] > Betreff: Version condition > > Hi, > > First of all, thanks, Antoine for getting out the beta today. > > I felt the need for a <antversion> condition today. I am aware > of the different techniques used - i.e., using the ant.version > property or using <available> and checking for a classname > that is unique to a particular release of Ant. <available> usually > works ok for major releases, but for minor ones, it may not > always. > > My situation is this: > I want to do the following if Ant runtime version is <= 1.6.1: > > <exec dir="${build.war}" executable="jar"> > <arg line="-cf ${build.ear}/${application.name}.war *"/> > </exec> > > I want to do the following if Ant runtime version is > 1.6.1 > (including beta > releases) > <jar jarfile="${build.ear}/${application.name}.war" > basedir="${build.war}" roundup="false"/> > > Currently I am doing something like this: > <condition property="no.roundup.support"> > <or> > <equals arg1="${ant.version}" arg2="1.6"/> > <contains string="${ant.version}" substring="1.6.1"/> > <contains string="${ant.version}" substring="1.5"/> > <contains string="${ant.version}" substring="1.4"/> > ..and so on... > </or> > </condition> > > <target name="exec_jar_war" if="no.roundup.support"> > <exec dir="${build.war}" executable="jar"> > <arg line="-cf ${build.ear}/${application.name}.war *"/> > </exec> > </target> > > <target name="rounddown_jar_war" unless="no.roundup.support"> > <jar jarfile="${build.ear}/${application.name}.war" > basedir="${build.war}" roundup="false"/> > </target> > > <target name="jar_war" depends="exec_jar_war,rounddown_jar_war"/> > > Is there a reliable built-in way (or a more elegant way) of > achieving this? > > Cheers, > Magesh > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] >