【发布时间】:2015-08-06 14:05:23
【问题描述】:
我使用 android.bat 为我的 android 项目创建 ant build.xml。
现在我在 build.xml 中找到了这些代码:
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
但我认为这段代码意味着如果设置了env.ANDROID_HOME,sdk.dir 将是${env.ANDROID_HOME}。此代码如何检查sdk.dir 是否已设置?
为什么要投反对票?在 Apache Ant 用户手册中:
如果条件成立,则属性值默认设置为true;否则,不设置该属性。您可以通过指定 value 属性将值设置为默认值以外的值。
它只是说该属性将根据条件的结果设置为某个值。我不明白意思:If the property is set , the condition won't work.
【问题讨论】: