正确的一个:ant verifyParameters -DrestoreValue=false
例如:ant verifyParameters -Drestoreval=false
如果参数拼写错误,我想抛出一个错误,即使我传递了多个参数,它也应该抓住所有参数并抛出一个错误。
这里是一个例子。如果未设置参数default
,则主要目标check-parameter
被依赖目标restoreValue
屏蔽,该目标将失败。
<project name="option-test" default="default">
<!--
This is the main target. It depends on target check-parameter which fails,
if parameter restoreValue is not set.
-->
<target name="default" depends="check-parameter">
<echo message="Start build ..." />
<echo message="restoreValue = ${restoreValue}" />
</target>
<!--
This helper target sets property parameterok to true, if restoreValue is set.
And to false, otherwise.
-->
<target name="check-is-set">
<condition property="parameterok">
<isset property="restoreValue"/>
</condition>
</target>
<!--
This target depends on target check-is-set, which calculates the parameterok property.
The unless attribute evaluates the parameterok property, so that the target body
is only excuted, if paramterok=false.
So the build fails only if parameter restoreValue is not set.
-->
<target name="check-parameter" unless="${parameterok}" depends="check-is-set">
<fail message="Parameter restoreValue not set!" />
</target>