ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "broken connection" <brokenconnect...@gmail.com>
Subject Variable task - unset attribute issue
Date Thu, 12 Jul 2007 17:29:18 GMT
Hi Friends,
I am having a problem with empty strings. I have this simple build file:

 <project name="test" default="test_iteration">
 <taskdef resource="net/sf/antcontrib/antlib.xml" />

 <target name="test_iteration">
         <var name="counter" value="0"/>
        <for list="parameter1,parameter2,parameter3" param="arg" >

        <sequential>

        <math result="counter" operand1="${counter}" operation="+"
operand2="1" datatype="int"/>
        <var name="output.property" unset="true"/>

        <java classname="GeneratePassword" fork="true">
            <arg value="@{arg}" />
            <redirector outputproperty="output.property" />
        </java>

        <if>
            <equals arg1="${counter}" arg2="1"/>
            <then>
                <property name="property1" value="${output.property}" />
                <echo>1:${property1}</echo>
            </then>

        <elseif>
            <equals arg1="${counter}" arg2="2"/>
            <then>
                <property name="property2" value="${output.property}" />
                <echo>2:${property2}</echo>
            </then>
        </elseif>

        <elseif>
            <equals arg1="${counter}" arg2="3"/>
            <then>
                <property name="property3" value="${output.property}" />
                <echo>3:${property3}</echo>
            </then>
        </elseif>

        </if>
        </sequential>
        </for>
 </target>
</project>

output:

test_iteration:
     [echo] 1:PARAMETER1
     [echo] 2:PARAMETER2
     [echo] 3:PARAMETER3



Now,if I pass the second parameter as EMPTY STRING i.e:
    .....
    <for list="parameter1,,parameter3" param="arg" >
    ....

Actual Output I get:

test_iteration:
     [echo] 1:PARAMETER1
     [echo] 2:PARAMETER3


Expected Output I get:

test_iteration:
     [echo] 1:PARAMETER1
     [echo] 3:PARAMETER3

So,can someone explain me when I pass in an empty string, why the second
loop runs instead of third.I think this "unset" is the cause of the error:
<var name="output.property" unset="true"/>

But can someone please tell me how to resolve this.My test java class is
very simple,it takes a argument and returns the uppercase of that...so when
so argument is specified,it returns nothing.

Thanks

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message