Search code examples
eclipseantant-contrib

ant-contrib needed in 1.8.2 build.xml, but causes errors


I find I need the following in build.xml:

<taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath>
        <pathelement location="${ant.library.dir}/ant-contrib-1.0b3.jar" />
    </classpath>
</taskdef>

in order to support the ant-contrib <if> ... </if> construct I'm using. However, Eclipse is very grumpy about this. With this section at the top of build.xml, everything works perfectly, whether from the command line outside of Eclipse or inside Eclipse, despite the grumpiness:

enter image description here

What "name" is in fact "undefined"? I would dearly like to understand what to do about this problem. Googling, I see others have had identical or similar problems, but no one's given a good answer, at least not that fits my situation.

Profuse thanks for any comments on this problem,

Russ


Solution

  • I found the issue and simple work around described here: http://www.mail-archive.com/[email protected]/msg39536.html

    I confirmed that with the following build file:

    <project default="test">
    
      <!-- Eclipse complains if you comment this out   -->
      <property name="dummy" value="dummy"/>
    
      <taskdef resource="net/sf/antcontrib/antlib.xml">
        <classpath>
          <pathelement location="C:/lib/ant-contrib/ant-contrib-1.0b3.jar"/>
        </classpath>
      </taskdef>
    
      <target name="test">
      </target>
    
    </project>
    

    If you don't have a property declaration before the taskdef, Eclipse complains.

    Another work around I tried was to move the taskdef into a target. That worked too:

      <target name="test" depends="init">
      </target>
    
      <target name="init">
        <taskdef resource="net/sf/antcontrib/antlib.xml">
          <classpath>
            <pathelement location="C:/lib/ant-contrib/ant-contrib-1.0b3.jar"/>
          </classpath>
        </taskdef>
      </target>