You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Vijay Aravamudhan <av...@gmail.com> on 2007/10/25 18:33:24 UTC

Is there an ant task (inbuilt in ant core) to verify the version of a jre?

hi,
On many of my projects, we need to compile against the 1.4 JDK. 
Depending on what any individual developer might have installed, we run 
into issues with JDK versions ranging from 1.4.x, 1.5.x and 1.6.
Does anyone know if there is a task in ant which can be used to verify 
the version of the JDK and possibly fail the build if the version does 
not match what the project needs? (For eg: The limitation could be that 
the app server being used does not support more than JDK 1.4)

To get around this currently, I have the following lines at the top of 
the build file:
    <!-- allows non-standard tasks <foreach> and <if> -->
    <taskdef resource="net/sf/antcontrib/antlib.xml" 
classpath="lib/compile/ant-contrib.jar" />

    <!-- verify that the current java version is correct -->
    <if>
        <not>
            <equals arg1="${ant.java.version}" arg2="1.4" />
        </not>
        <then>
            <fail message="Not running ant with JDK 1.4 - this will 
result in differing class versions" />
        </then>
    </if>

But, as you can see, this creates a dependency on the ant-contrib jar. 
What I would like to achieve is the same - but without having to include 
the ant-contrib jar.

thanks,
Vijay

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


Re: Is there an ant task (inbuilt in ant core) to verify the version of a jre?

Posted by Peter Reilly <pe...@gmail.com>.
Use the fail task:
    <fail message="Not running ant with JDK 1.4 - this will
result in differing class versions">
      <condition>
        <not>
          <equals arg1="${ant.java.version}" arg2="1.4" />
        </not>
      </condition>
    </fail>

Be aware however taht using the target and source attributes for
the javac task will generate correct class versions.
Peter


On 10/25/07, Vijay Aravamudhan <av...@gmail.com> wrote:
> hi,
> On many of my projects, we need to compile against the 1.4 JDK.
> Depending on what any individual developer might have installed, we run
> into issues with JDK versions ranging from 1.4.x, 1.5.x and 1.6.
> Does anyone know if there is a task in ant which can be used to verify
> the version of the JDK and possibly fail the build if the version does
> not match what the project needs? (For eg: The limitation could be that
> the app server being used does not support more than JDK 1.4)
>
> To get around this currently, I have the following lines at the top of
> the build file:
>     <!-- allows non-standard tasks <foreach> and <if> -->
>     <taskdef resource="net/sf/antcontrib/antlib.xml"
> classpath="lib/compile/ant-contrib.jar" />
>
>     <!-- verify that the current java version is correct -->
>     <if>
>         <not>
>             <equals arg1="${ant.java.version}" arg2="1.4" />
>         </not>
>         <then>
>             <fail message="Not running ant with JDK 1.4 - this will
> result in differing class versions" />
>         </then>
>     </if>
>
> But, as you can see, this creates a dependency on the ant-contrib jar.
> What I would like to achieve is the same - but without having to include
> the ant-contrib jar.
>
> thanks,
> Vijay
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

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