如何比较ANT脚本字符串 [英] How to compare strings in ANT script

查看:236
本文介绍了如何比较ANT脚本字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个Ant脚本建立我的iOS应用。我希望用户输入该IPA文件应该被创建的环境名称。例如开发或生产或QA或UAT。我有下面的代码片段,以接受用户输入并存储在一个名为物业环境:

I am writing an ANT script to build my iOS app. I want the user to enter the environment name for which the ipa file should be created. e.g. development or production or QA or UAT. I have the below snippet to accept user input and store it in a property named environment:

<input
message="Enter targeted environment (dev or QA1 or QA2 or UAT1 or UAT2 or staging or perf or prod)"
addproperty="environment"
/>

在用户输入环境名称后,我要检查用户输入的内容。然后,我要叫这取决于用户输入不同的目标。是这样的:

After the user enters the environment name, I have to check what the user has entered. Then I have to call different targets depending on the user input. Something like:

if (environment== "development")
  // call dev target
else if (environment== "production")
 // call prod target
else if (environment== "QA")
 // call QA target
else if (environment== "UAT")
 // call UAT target

我怎样才能做到这一点?有人可以帮我...谢谢..

How can I achieve this? Can somebody please help me… Thanks..

推荐答案

我强烈建议你放弃你的取得用户输入的计划。建立不应该把用户输入的,如果你想自动执行它会发生什么?我认为所有的建立采取任何交互式输入。

I strongly urge you to abandon your plan of taking user input. builds shouldn't take user input, what happens if you want to automate it? I assume all builds take no interactive inputs.

您最好的办法是始终指定你想要的目标。

Your best plan would be to always specify the target you want.

蚂蚁QA

下一个最好的将是在命令行中指定的环境属性

next best would be to specify the environment property on the commandline

蚂蚁-Denv =开发

有没有如果蚂蚁。你可能会引诱蚂蚁的contrib,这是不是路径。如果你发现自己需要它,你可能会更适合用不同的构建工具或编写自己的Ant任务。

There is no if in ant. You may be lured into ant-contrib, this isn't the path. If you find yourself needing it, likely you would be better suited with a different build tool or writing your own ant task.

如果你想实现你所说,你可以设置条件,设置属性,然后改变你的目标,有条件地通过这样的如果属性运行它们的方案:

If you wanted to implement the scheme you described you could setup conditions to set properties and then change your targets to conditionally run them with the if attribute like this:

<condition property="env.is.dev"> 
    <equals arg1="${env}" arg2="dev"/> 
</condition> 

<target name="dev" if="${env.is.dev}">

如果该属性设置的属性,如果执行目标。

the if attribute executes the target if the property is set.

这篇关于如何比较ANT脚本字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆