0
votes

I create ant build.xml for my android project using android.bat.

Now I found those code in 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>

But I think this code means if env.ANDROID_HOME is set, sdk.dir will be ${env.ANDROID_HOME}. How can this code check whether the sdk.dir was set or not?

Why down vote? In Apache Ant User Manual:

If the condition holds true, the property value is set to true by default; otherwise, the property is not set. You can set the value to something other than the default by specifying the value attribute.

It only says the property will be set to some value according to condition's result. I can't get the meaning : If the property is set , the condition won't work.

1

1 Answers

1
votes

In Ant properties are immutable unless you use the local scope.

So if sdk.dir was set before from a property file then the second assignment in condition will be ignored.

You can run ant -verbose to see what is happening.