Use the if attribute on the target element, for example:
<project name="test" default="init"> <target name="init" if="${path}"> </target> </project>
Second option: more detailed
<project name="test" default="init"> <target name="init"> <fail message="Path is not set! Exiting ant script!"> <condition> <not> <isset property="${path}"/> </not> </condition> </fail> </target> </project>
source share