Q:

How to read properties file in ant

Hi all these are the contents of my file.properties file and i want to print those platforms which have true valu and their installer location,it is sure that the platform which has true value will only have installer:
platform.win-x86=true
platform.win-x86-client=false
platform.win-x64=true
platform.linux-x86=false
installer-zip.win-x86=E:\\abc\\abc.jar
installer-zip.win-x64=E:\\def\\def.jar
tried many thing but could not one of the things i used was as 
 <propertyselector property="platform.list"
                         delim`enter code here`iter=","
                         match="platform\.([^\.]*)"
                         select="\1"
                         casesensitive="false" />

    <propertyselector property="zip.list"
                         delimiter=","
                         match="installer-zip\.([^\.]*)"
                         select="\1"
                         casesensitive="false" />

   <target name="print.name" >
      <propertycopy name="platform.name" from="platform.${platform.id}" />
      <if> <equals arg1="${platform.name}" arg2="true" />
            <then>
                <echo>PlatForm. Id====>${platform.id}</echo>
                <echo message="${platform.name}" />
                <echo file="platform.properties" append="yes">${new.platform-name}=Yes${line.separator}</echo>
            </then>

        </if>
    </target> 

    <target name="print.zipname" >
        <propertycopy name="zip.name" from="installer-zip.${zip.id}" />
        <echo>zip. Id====>${zip.id}</echo>
        <echo message="${zip.name}" />

    </target> 

    <target name="first">  
         <foreach list="${platform.list}"
                delimiter=","
                target="print.name"
                param="platform.id" />

        <foreach list="${zip.list}"
                delimiter=","
                target="print.zipname"
                param="zip.id" />
    </target> 

although it prints value for all true platforms but for installer it prints only 1,and then breaks..can you help please

A:

This is not directly answering your question, but rather showing you how you could use the same properties to perform conditional targets in your build. 
<project default="build">

    <property file="platform.properties"/>

    <condition property="build.win-x86">
        <and>
            <istrue value="${platform.win-x86}"/>
            <isset property="installer-zip.win-x86"/>
        </and>
    </condition>
    <condition property="build.win-x86-client">
        <and>
            <istrue value="${platform.win-x86-client}"/>
            <isset property="installer-zip.win-x86-client"/>
        </and>
    </condition>
    <condition property="build.win-x64">
        <and>
            <istrue value="${platform.win-x64}"/>
            <isset property="installer-zip.win-x64"/>
        </and>
    </condition>
    <condition property="build.linux-x86">
        <and>
            <istrue value="${platform.linux-x86}"/>
            <isset property="installer-zip.linux-x86"/>
        </and>
    </condition>

    <target name="build" depends="win-x86, win-x86-client, win-x64, linux-x86"/>

    <target name="win-x86" depends="win-x86-build, win-x86-installer"/>
    <target name="win-x86-client" depends="win-x86-client-build, win-x86-client-installer"/>
    <target name="win-x64" depends="win-x64-build, win-x64-installer"/>
    <target name="linux-x86" depends="linux-x86-build, linux-x86-installer"/>

    <target name="win-x86-build" if="${build.win-x86}">
        <echo message="executing win-x86-build"/>
    </target>
    <target name="win-x86-installer" if="${build.win-x86}">
        <echo message="installer: ${installer-zip.win-x86}"/>
    </target>

    <target name="win-x86-client-build" if="${build.win-x86-client}">
        <echo message="executing win-x86-client-build"/>
    </target>
    <target name="win-x86-client-installer" if="${build.win-x86-client}">
        <echo message="installer: ${installer-zip.win-x86-client}"/>
    </target>

    <target name="win-x64-build" if="${build.win-x64}">
        <echo message="executing win-x64-build"/>
    </target>
    <target name="win-x64-installer" if="${build.win-x64}">
        <echo message="installer: ${installer-zip.win-x64}"/>
    </target>

    <target name="linux-x86-build" if="${build.linux-x86}">
        <echo message="executing linux-x86-build"/>
    </target>
    <target name="linux-x86-installer" if="${build.linux-x86}">
        <echo message="installer: ${installer-zip.linux-x86}"/>
    </target>

</project>

The output based on your properties file is below.  Note that only the win-x86 and win-64 targets were actually executed.  The others were skipped because the required conditions were not satisfied:
win-x86-build:
     [echo] executing win-x86-build

win-x86-installer:
     [echo] installer: E:\abc\abc.jar

win-x86:

win-x86-client-build:

win-x86-client-installer:

win-x86-client:

win-x64-build:
     [echo] executing win-x64-build

win-x64-installer:
     [echo] installer: E:\def\def.jar

win-x64:

linux-x86-build:

linux-x86-installer:

linux-x86:

build:

BUILD SUCCESSFUL
Total time: 0 seconds

