ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <peter.kitt.rei...@gmail.com>
Subject Re: Trouble with simple for loops
Date Thu, 05 Feb 2009 23:27:20 GMT
you have to use the antlib.xml form of taskdef and not the antcontrib.properties
form. The antcontrib.properties is for ant 1.5 and lower, the
antlib.xml form is for
ant 1.6 and higher.

Use the following:
<project xmlns:ac="antlib:net.sf.antcontrib">

<typedef  uri="antlib:net.sf.antcontrib"
        classpath="PATH_TO_ANTCONTRIB"/>

<ac:for list="a,b,c,d,e" param="iter">
   <sequential>
    <echo>@{iter}</echo>
  </sequential>
</project>

Peter



On Thu, Feb 5, 2009 at 10:06 PM, Steve Liu <stevecliu@gmail.com> wrote:
> Hi,
>
> I'm trying to get the following to work
> <?xml version="1.0" encoding="UTF-8"?>
> <project basedir="." default="build.all.modules" name="Build_DD_Modules">
>  <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
>  <target name="init">
>  </target>
>  <target name="build.all.modules" depends="init">
>    <for list="a,b,c,d,e" param="letter">
>      <sequential>
>        <echo>Letter @{letter}</echo>
>      </sequential>
>    </for>
>  </target>
> </project>
>
> However, when I run it. I get:
>
>
> I've searched the list, but I'm not trying anything fancy like junit... so I
> can't think of any jars I could need. But here is my classpath, in case it's
> useful...
> .;C:\Program Files\Java\jre1.5.0_11\lib\ext\QTJava.zip
> Apache Ant version 1.7.1 compiled on June 27 2008
> Buildfile: build.xml
> Detected Java version: 1.5 in: C:\Program Files\Java\jdk1.5.0_11\jre
> Detected OS: Windows XP
> parsing buildfile C:\test\build.xml with URI = file:/C:/test/build.xml
> Project base dir set to: C:\test
> [antlib:org.apache.tools.ant] Could not load definitions from resource
> org/apache/tools/ant/antlib.xml. It could not be found.
>  [taskdef] Could not load definitions from resource
> net/sf/antcontrib/antcontrib.properties. It could not be found.
> Build sequence for target(s) `build.all.modules' is [init,
> build.all.modules]
> Complete build sequence is [init, build.all.modules, ]
>
> init:
>
> build.all.modules:
>
> BUILD FAILED
> C:\test\build.xml:8: 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.
>
>        at
> org.apache.tools.ant.UnknownElement.getNotFoundException(UnknownElement.java:484)
>        at
> org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:416)
>        at
> org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:160)
>        at org.apache.tools.ant.Task.perform(Task.java:347)
>        at org.apache.tools.ant.Target.execute(Target.java:357)
>        at org.apache.tools.ant.Target.performTasks(Target.java:385)
>        at
> org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
>        at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
>        at
> org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
>        at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
>        at org.apache.tools.ant.Main.runBuild(Main.java:758)
>        at org.apache.tools.ant.Main.startAnt(Main.java:217)
>        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
>        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
>
> Total time: 0 seconds
>
> Can someone help?
>
> Thanks,
> Steve
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message