What is the most efficient way of checking if an environment variable has been set prior to executing the rest of an Ant script?
Let’s say my Ant script requires the environment variable “FOO” to be set. I got the following to work, but I was wondering whether there was a less convulated way of achieving the same result:
<property environment="env"/>
<property name="env.FOO" value=""/>
<target name="my-target">
<condition property="foo.found">
<not>
<equals arg1="${env.FOO}" arg2=""/>
</not>
</condition>
<fail unless="foo.found" message="FOO not set."/>
<!-- do stuff here that uses the FOO environment variable -->
</target>
Isn’t this as simple as: