“if-else”如何实现?使用“条件”来模拟逻辑?
我知道有ant-contrib
,它为ant提供了“if-else”逻辑。 但我需要实现相同的没有ant-contrib
。这可能吗?
我需要工作的伪代码:
if(property-"myProp"-is-true){
do-this;
}else{
do-that;
}
谢谢!
I know that there is ant-contrib
, which provides "if-else" logic for ant.
But I need to achieve the same without ant-contrib
. Is that possible?
Pseudocode which I need to work:
if(property-"myProp"-is-true){
do-this;
}else{
do-that;
}
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
无论如何,我强烈建议使用 ant-contribs,但如果您正在测试一个始终具有值的属性,我会考虑使用 ant 宏参数作为您随后测试的新属性的名称的一部分
I would strongly recommend using ant-contribs anyway but if you are testing a property that always has a value I would look into using an ant macro parameter as part of the name of a new property that you then test for
您可以在目标中添加“if”属性。
仅当设置了“myProp”时才会触发。您需要在其他地方定义 myProp,以便在您希望触发此目标时对其进行设置。如果你不这样做就不会。您可以使用 except 作为替代情况:
You can put an "if" attribute in your targets.
This will fire only if "myProp" is set. You'll need to define myProp elsewhere such that it's set if you want this target to fire & not if you don't. You can use unless for the alternate case: