Ant-Contrib for loop error

Warning: Illegal string offset 'language' in /var/www/vhosts/ on line 510 Warning: ksort() expects parameter 1 to be array, string given in /var/www/vhosts/ on line 513

When trying to use Ant-Contrib for loops today, I ran into the error below:

C:\Projects\…\ant\build.xml:200: 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.

To fix the error I had to update the Ant-Contrib taskdef resource path from using “” to use “antlib.xml” in my Ant build file.

  1. // Remove this line
  2. <taskdef resource="net/sf/antcontrib/>
  3. // And replace with this one
  4. <taskdef resource="net/sf/antcontrib/antlib.xml">

According to the Ant-Contrib manual (found in [Ant-Contrib install dir]/docs/manual/index.html) you need to use the “” file when you want Ant-Contrib to run with Ant Version 1.5. They even place a warning saying:

Keep in mind that some tasks will not be available to you , such as the <for> task

The confusing part is that on the project page they tell you to use the “” file.

Leave a Reply

Your email address will not be published. Required fields are marked *