other option at place of <bool> tag

做~自己de王妃 提交于 2019-12-24 02:57:16

问题


<if>
   <bool>
      <isgreaterthan arg1="${abc}" arg2="${xyz}"/>
   </bool>
</if>

when i am running the code, it's showing the error if doesn't support the nested "bool" element. is there any other option is there at the place of bool which supported by if


回答1:


Ant Flaka is a new Ant Plugin that provides an innovative Expression Language which makes many scripting part obsolete. Beside that Flaka provides conditional and repetitive control structures like when, unless, while, for, choose, switch .. Your if statement with Flaka would look like =

<project xmlns:fl="antlib:it.haefelinger.flaka">

  <property name="digitA" value="42"/>
  <property name="digitB" value="23"/>
  <property name="wordA"  value="abcd"/>
  <property name="wordB"  value="efgh"/>

  <!-- compare of digits -->
  <fl:when test=" '${digitA}' > '${digitB}' ">
    <echo>${digitA} gt ${digitB}</echo>
  </fl:when>

  <!-- example with string compare in switch -->
  <fl:switch value="${wordA}">
    <cmp gt="${wordB}">
      <echo>${wordA} gt ${wordB}</echo>
    </cmp>
    <cmp lt="${wordB}">
    <echo>${wordA} lt ${wordB}</echo>
    </cmp>
  </fl:switch>

</project>

please see the comprehensive Flaka Manual for further details !




回答2:


The example works in antcontrib-1.0b2 but not the latest antcontrib-1.0b3

Found this after hitting a similar problem after an update




回答3:


It looks like you're attempting to use the Antelope if task, as it (unlike the ant-contrib if) supports a nested bool element. But, the error message is indicative of the task not being defined correctly.

Check that you have the Antelope jar, and a suitable taskdef in your buildfile. I use this:

<taskdef resource="ise/antelope/tasks/antlib.xml"
         classpath="path/to/AntelopeTasks_3.5.1.jar" />

For details of what the task supports, see the documentation linked to above.




回答4:


You can use 'bool' tag within 'if' provided you use taskdef for "if" using the classname="ise.antelope.tasks.IfTask"

Eg:

<target name="compare">  <taskdef name="if" classname="ise.antelope.tasks.IfTask"/>  <var name="abc" value="2" />  <var name="xyz" value="1" />  <if>  <bool>  <isgreaterthan arg1="${abc}" arg2="${xyz}"/>  </bool>  <echo message="${abc} is greater than ${xyz}" />  </if>  </target>


来源:https://stackoverflow.com/questions/5473706/other-option-at-place-of-bool-tag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!