user2783146
user2783146

Reputation: 11

if doesn't support the nested "equals" element in ant build file

Below is my code. We are using Ant verison 1.9.11 and tried with the ant-contrib-1.0b3.jar and ant-contrib-1.0b2.jar.

<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>

<target name=abc>
<if>
  <equals arg1="${xyz}" arg2="true"/>
  <then>
    <replace file="src/com/xyz.java" token="DEBUG = false;" value="DEBUG = true;" />
  </then>
  <else>
    <echo message="${xyz} is not enabled "/>
  </else>           
</if>   
</target>

I've also tried using the full path of ant contrib like below, but am still getting the same errors.

<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
  <pathelement location="/opt/apache-ant-1.9.11/lib/ant-contrib-1.0b3.jar"/>
</classpath>

It would be really appreciate help me fix this issue.

Upvotes: 0

Views: 827

Answers (1)

martin clayton
martin clayton

Reputation: 78105

According to the antcontrib site, the taskdef using antcontrib.properties is for Ant version 1.5 only, so you need to use the antlib.xml taskdef instead. And you will need the nested classpath you tried, so likely in your case you need something like:

<taskdef resource="net/sf/antcontrib/antlib.xml">
  <classpath>
    <pathelement location="/opt/apache-ant-1.9.11/lib/ant-contrib-1.0b3.jar"/>
  </classpath>
</tsakdef>

Upvotes: 1

Related Questions