Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check Ant version inside Ant script

Tags:

java

ant

My ant script only works with version >=1.8. I want to check the version in the script, so that it displays error if a lesser version installed.

like image 661
Sumeet Jindal Avatar asked May 09 '12 10:05

Sumeet Jindal


People also ask

How do I change my Ant version?

Window > Preferences > Ant > Runtime.1 are grouped under the Ant Home Entries item. To change the Ant Home entries, click on the Ant Home... button and choose the Ant installation you wish to use. After you change the Ant classpath, all future Ant builds will use the updated version instead of the default.

What version of Java is Ant using?

1. Which version of Java is required to run Apache Ant? You will need Java installed on your system, version 1.8 or later required. The later the version of Java, the more Ant tasks you get.

What is Ant in command line?

ANT stands for Another Neat Tool. It is a Java-based build tool from computer software development company Apache.


1 Answers

Here's a code snip that may help:

<property name="version.required" value="1.8" />

<target name="version_check">
    <antversion property="version.running" />
    <fail message="FATAL ERROR:  The running Ant version, ${version.running}, is too old.">
        <condition>
            <not>
                <antversion atleast="${version.required}" />
            </not>
        </condition>
    </fail>
</target>

<target name="doit" depends="version_check">
    <echo level="info" message="The running version of ant, ${version.running}, is new enough" />
</target>

like image 193
Cyril Sagan Avatar answered Sep 21 '22 21:09

Cyril Sagan