other option at place of tag

2019-07-08 20:28发布

<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

标签: ant
4条回答
We Are One
2楼-- · 2019-07-08 20:32

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>
查看更多
你好瞎i
3楼-- · 2019-07-08 20:35

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 !

查看更多
淡お忘
4楼-- · 2019-07-08 20:49

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

Found this after hitting a similar problem after an update

查看更多
Luminary・发光体
5楼-- · 2019-07-08 20:51

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.

查看更多
登录 后发表回答