gpt4 book ai didi

ant - 如何使用 "if-else"模拟 "condition"逻辑?

转载 作者:行者123 更新时间:2023-12-01 10:13:41 25 4
gpt4 key购买 nike

我知道有ant-contrib,它为ant提供了“if-else”逻辑。但我需要实现相同的没有 ant-contrib。这可能吗?

我需要使用的伪代码:

if(property-"myProp"-is-true){
do-this;
}else{
do-that;
}

谢谢!

最佳答案

无论如何,我强烈建议使用 ant-contribs,但如果您正在测试一个始终具有值的属性,我会考虑使用 ant 宏参数作为您随后测试的新属性名称的一部分

<macrodef name="create-myprop-value">
<attribute name="prop"/>
<sequential>
<!-- should create a property called optional.myprop.true or -->
<!-- optional.myprop.false -->
<property name="optional.myprop.@{prop}" value="set" />
</sequential>
</macrodef>

<target name="load-props">
<create-myprop-value prop="${optional.myprop}" />
</target>

<target name="when-myprop-true" if="optional.myprop.true" depends="load-props">
...
</target>

<target name="when-myprop-false" if="optional.myprop.false" depends="load-props">
...
</target>

<target name="do-if-else" depends="when-myprop-true,when-myprop-false">
...
</target>

关于ant - 如何使用 "if-else"模拟 "condition"逻辑?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3200056/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com