Orangevolt ANT Tasks » Tasks » properties
Element propertyfind

2.5.3.  Example

build.xml
<?xml version="1.0"?>  
 
<project basedir="." name="properties-test" default="main">
  <taskdef classpath="orangevolt-ant-tasks-1.3.2.jar" resource="com/orangevolt/tools/ant/taskdefs.properties"/>
    
    
  <target name="main">
    <property name="myProp" value="hach"/>
      
    <properties file="deploy/test.properties">
      <header>
        a header (myProp=${myProp})
      </header>
        <!--
          merge all property files in directory deploy
        -->
      <merge dir="deploy" includes="**/*.properties"/>
        
        <!-- add property "one" -->
      <property name="one" value="1"/>
        
        <!--
          add property "myProp_exists"
          if a property "myProp" exists
          (-> will succeed)
        -->
      <property name="myProp_exists" value="yes" if="myProp"/>
 
        <!--
          add property "yourProp_exists"
          if a property "yourProp" exists
          (-> will fail)
        -->
      <property name="yourProp_exists" value="yes" if="yourProp"/>
 
        <!--
          add property "myProp_notexists"
          if property "myProp" not exists
          (-> will fail)
        -->
      <property name="myProp_notexists" value="yes" unless="myProp"/>
        
        <!--
          add property "yourProp_notexists"
          if property "yourProp" not exists
          (-> will succeed)
        -->
      <property name="yourProp_notexists" value="yes" unless="yourProp"/>
        
        <!--
          add property "class_test_available"
          if a class or resource "test" exists
          (-> will fail)
        -->
      <property name="class_test_available" value="yes" available="test"/>
        
        <!--
          add property "class_com_orangevolt_tools_ant_PropertiesTask_exists"
          if class or resource "com.orangevolt.tools.ant.PropertiesTask" exists
          (-> will succeed)
        -->      
      <property name="class_com_orangevolt_tools_ant_PropertiesTask_exists" value="yes" available="com.orangevolt.tools.ant.PropertiesTask"/>
        
        <!--
          add property "trueistrue"
          if istrue attribute value is "true"
          (-> will succeed)
        -->
      <property name="trueistrue" value="yes" istrue="true"/>
 
        <!--
          add property "falseistrue"
          if istrue attribute value is "false"
          (-> will fail)
        -->
      <property name="falseistrue" value="yes" istrue="false"/>
 
        <!--
          add property "trueisfalse"
          if isfalse attribute value is "false"
          (-> will fail)
        -->
      <property name="trueisfalse" value="yes" isfalse="true"/>
 
        <!--
          add property "falseisfalse"
          if isfalse attribute value is "false"
          (-> will succeed)
        -->
      <property name="falseisfalse" value="yes" isfalse="false"/>
    </properties>
  </target>
</project>