我想检查ant构建脚本的参数是否设置。我尝试了很多方法来做到这一点,但没有成功。我用-Dmaindir="../propertyfolderpath"
定义了参数。参数不为空
这是我试过的代码示例;
<ac:if>
<equals arg1="@{maindir}" arg2="" />
<ac:then>
<echo message="maindir argument is empty. Current properties will be used." />
<property file="build.properties" />
</ac:then>
<ac:else>
<echo message="maindir = ${maindir}" />
<ac:if>
<ac:available file="${maindir}/build.properties" type="file" />
<ac:then>
<property file="${maindir}/build.properties" />
</ac:then>
<ac:else>
<fail message="${maindir} is not a valid path." />
</ac:else>
</ac:if>
</ac:else>
</ac:if>
- 有三种情况;
- 参数可能未定义。蚂蚁应该先进入
- 参数定义的很好。用错误的道路
对于第二种情况脚本定义
为什么蚂蚁会这样做?
我建议'[默认]'会变成'$ {basedir}' – 2011-06-15 10:13:50
thx。这也适用于我。 Laepdjek和你的答案都是正确的。我用了两个答案。谢谢。而且Arne你是对的。我已经像'$ {basedir}'一样使用它了。 – Aykut 2011-06-15 10:39:40