ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Moore, Kent" <Kent.Mo...@fnis.com>
Subject RE: Best way to have script fail if not using new enough JDK?
Date Mon, 21 Dec 2009 00:11:55 GMT

We enforce the java version using one of these two routines in our init target:

        <!-- check for java version and fail build immediately if not using the correct
version -->
        <echo message="Java Version: ${java.version}"/>
        <echo message="Java home: ${java.home}"/>
        <fail message="Unsupported Java version: ${java.version}. Make sure that the version
of the Java compiler is 1.6.">
            <condition>
                <not>
                    <contains string="${java.version}" substring="1.6" casesensitive="false"
/>
                </not>
            </condition>
        </fail>


or, to allow a minimum java version - 

        <!-- check for java version and fail build immediately if not using the correct
version -->
        <echo message="Java Version: ${java.version}"/>
        <echo message="Java home: ${java.home}"/>
        <fail message="Unsupported Java version: ${java.version}. Please make sure the
version of the Java compiler is 1.5 (5.0) or greater.">
            <condition>
                <not>
                    <or>
                        <contains string="${java.version}" substring="1.5" casesensitive="false"
/>
                        <contains string="${java.version}" substring="1.6" casesensitive="false"
/>
                    </or>
                </not>
            </condition>
        </fail>




-----Original Message-----
From: KARR, DAVID (ATTCINW) [mailto:dk068x@att.com]
Sent: Sun 12/20/2009 6:44 PM
To: Ant Users List
Subject: Best way to have script fail if not using new enough JDK?
 
I need to have my Ant script abort if the current JDK version is older
than the project needs (1.6).

I noticed a "JavaVersionTask" sample at <http://onjava.com/lpt/a/6264>
which would probably help, but I wonder if there's an easier way since
that article was written (4 years ago).

I can see the possibility of doing this with a Groovy scriptcondition to
set the property to check, but I can't figure out how I can get Groovy
to set Ant properties, or to return a value that would set the property.

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





_____________

The information contained in this message is proprietary and/or confidential. If you are not
the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose,
distribute or use the message in any manner; and (iii) notify the sender immediately. In addition,
please be aware that any message addressed to our domain is subject to archiving and review
by persons other than the intended recipient. Thank you.
_____________


Mime
View raw message