Ant build error in the absence of command line parameters

I am sending the file path as a parameter to ant on the command line. I want the assembly to fail if the parameter does not exist. What is the way to do this?

Thanks!

+4
source share
1 answer

Use the if attribute on the target element, for example:

<project name="test" default="init"> <target name="init" if="${path}"> <!--This will only execute if ${path} is defined from the command line--> </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> 
+5
source

All Articles