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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]