One of the common mistake when checking the property value in the ant build file is putting $ in the condition check in the isset flag. for isset , just specifying the property name is fine, and $ is not required. If $ specify, it will take the property value and checks property value as a property or not. below is the sample ant build file code .
Defining a new property in Ant build file: property, name and value are key words. Syntax is given below. there is no data type for the property. we can give any value like, string, numeric or directory path, file path etc.
<!-- defining a new property -->
<property name="test" value="this is variable"/>
Accessing a property value Ant build file: We can access property value by using $. Prepend $ for the property name and use in the echo, condition check etc. Below is the property value access in echo.
<!-- accessing a property value -->
<echo message="test value is $test"/>
correct way of using isset: $ is not required in the condition check
wrong way of using isset: Putting $ is a wrong way
Defining a new property in Ant build file: property, name and value are key words. Syntax is given below. there is no data type for the property. we can give any value like, string, numeric or directory path, file path etc.
<!-- defining a new property -->
Accessing a property value Ant build file: We can access property value by using $. Prepend $ for the property name and use in the echo, condition check etc. Below is the property value access in echo.
<!-- accessing a property value -->
<echo message="test value is $test"/>
correct way of using isset: $ is not required in the condition check
<if> <isset property="test"/> <then> <!-- success and test is a property--> </then> </if>
wrong way of using isset: Putting $ is a wrong way
<if> <isset property="$test"/> <then> <!-- it wont come here, because $test is not a property--> </then> </if>
No comments:
Post a Comment