我将文件路径作为参数发送到命令行。如果参数不存在,我希望构建失败。怎么做呢?
谢谢!
在目标上使用if属性,例如:
<project name="test" default="init">
<target name="init" if="${path}">
<!--This will only execute if ${path} is defined from the command line-->
</target>
</project>
第二个选项:更详细
<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>