Home > Back-end >  Problem: failed to create task or type for Cause: The name is undefined
Problem: failed to create task or type for Cause: The name is undefined

Time:09-21

I was trying to iterate a list using for tag in my build.xml. But getting this error:

D:\Workspaces\myWorkspace\POC\build.xml:15: Problem: failed to create task or type for
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.

My build .xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<project name="POC" default="test" basedir=".">
    <description>
        simple example build file
    </description>
   
  <target name="test" >
    <echo message="test"/>
    <for list="a,b,c,d" delim="," param="x">
        <sequential>
            <echo message="${x}" />
        </sequential>
    </for>
  </target>
</project>

Can anybody tell where I am doing wrong, I am using eclipse 3.5 which has ANT3.7

CodePudding user response:

you imported the jar ant-contrib-1.0b3

lookup for it in eclipse/plugins/org.apache.ant_1.7.1.v20090120-1145/lib

in Eclipse, by Windows: Preferences-->Ant-->Runtime--->Add External Jars in Ant Home Entries.

edit to like this:

<?xml version="1.0" encoding="UTF-8"?>
<project name="POC" default="test" basedir="." xmlns:ac="antlib:net.sf.antcontrib">
    <description>
        simple example build file
    </description>
  <target name="test" >
    <echo message="test"/>
      
    <echo message="The first five letters of the alphabet are:"/>
    <ac:for list="a,b,c,d,e" param="letter">
      <sequential>
        <echo>Letter @{letter}</echo>
      </sequential>
    </ac:for>
 
  </target>
</project>
  •  Tags:  
  • list
  • Related