Som Sarkar Som Sarkar - 6 months ago 45
Java Question

Failing a ant build if the Java version is 1.5 or 1.6

I have an ant build file, which first checks what is the version of JAVA in my system. the code is like this-

<target name="">
<echo message="Ant java version: ${}" />

The output is -
[echo] Ant java version: 1.7

Now I want to make Build Fail if the java version is less than 1.7, how can I do that?

<target name="checkJava">
    <fail message="Unsupported Java version: ${java.version}. Make sure that the Java version is 1.7.">
                    <contains string="${java.version}" substring="1.7" casesensitive="false" /> 
                    <contains string="${java.version}" substring="1.8" casesensitive="false" />