17

contrib It's possible to check more condition in tag IF?
I need to do something like this :

<if>
<equals arg1="${var}" arg2="one"/>
<or>
    <equals arg1="${var}" arg2="two"/>
</or>
<or>
    <equals arg1="${var}" arg2="three"/>
</or>
<or>
    <equals arg1="${var}" arg2="four"/>
</or>
<then>
    <echo message="basic dir: ${var}"/>
    <copy todir="../direct" verbose="yes" failonerror="no" overwrite="yes">
        <fileset dir="${var}">
            <include name="**"/>
        </fileset>
    </copy>
</then></if>

How to do many conditions in one IF?

UPDATE: solve:

<if>
<or>
    <equals arg1="${var}" arg2="one"/>    
    <equals arg1="${var}" arg2="two"/>
    <equals arg1="${var}" arg2="three"/>
    <equals arg1="${var}" arg2="four"/>
</or>
<then>
    <echo message="basic dir: ${var}"/>
    <copy todir="../direct" verbose="yes" failonerror="no" overwrite="yes">
        <fileset dir="${var}">
            <include name="**"/>
        </fileset>
    </copy>
</then></if>
devduder
  • 394
  • 1
  • 10
Krzysztof Miksa
  • 1,519
  • 1
  • 16
  • 23
  • Is possible to delete my question? – Krzysztof Miksa Dec 03 '10 at 11:20
  • 1
    Krzysio - you shouldn't delete it, other users may have a similiar problem and may find your question and the answers useful. I'd remove the solution from the question and add it as an "own answer". That's the preferred way here on SO. The question is good enough to stay! – Andreas Dolk Dec 03 '10 at 11:29

1 Answers1

20

<If> is based on <condition> and supports (that's my understanding) the same nested elements (conditions).

Give this a try:

<if>
   <or>
    <equals arg1="${var}" arg2="one"/>
    <equals arg1="${var}" arg2="two"/>
    <equals arg1="${var}" arg2="three"/>
    <equals arg1="${var}" arg2="four"/>
   </or>
   <then>
    <echo message="basic dir: ${var}"/>
    <copy todir="../direct" verbose="yes" failonerror="no" overwrite="yes">
        <fileset dir="${var}">
            <include name="**"/>
        </fileset>
    </copy>
   </then>
</if>
Andreas Dolk
  • 113,398
  • 19
  • 180
  • 268