I've got a strange problem with ant. It's version is 1.7.1.
I'm trying to do next thing and get the error.
<target name="execute-all-buildfiles">
<foreach param="buildfile-path" target="execute-buildfile">
<path>
<dirset dir="${path.to.server}/share/source"/>
</path>
</foreach>
</target>
<target name="execute-buildfile">
<echo message="" />
<echo message="" />
<echo message="" />
<echo message="__________ Building cartridge ${buildfile-path} ___________" />
<echo message="" />
<echo message="" />
<echo message="" />
<java
jvm="${path.to.server}/engine/jdk/bin/java"
classname="org.apache.tools.ant.launch.Launcher"
fork="true"
failonerror="true">
<classpath>
<pathelement location="${ant.home}/lib/ant-launcher.jar"/>
</classpath>
<arg value="-f" />
<arg value="${buildfile-path}/build/build.xml" />
<arg value="-Dis.home=${path.to.server}" />
</java>
</target>
I've tried less complicated version of foreach, but it doesn't work as well. Please, help me.
<target name="run">
<foreach target="loop" param="loop.param">
<path>
<dirset dir="${path.to.server}/share/source"/>
</path>
</foreach>
</target>
<target name="loop">
<echo message="${loop.param}"/>
<basename property="dir.name" file="${loop.param}"/>
<echo message="${dir.name}"/>
</target>
P.S. Sorry for mistakes. Take a look at a simple one.
"Cause: The name is undefined" means the task is not installed in your ant environment.<foreach>
is not a task of vanilla ant but needs the ant addon antcontrib available for ant.
After installing antcontrib you should use <taskdef resource="net/sf/antcontrib/antlib.xml"/>
to activate all antcontrib tasks.
GOTCHA => Don't use <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
as mentioned on http://ant-contrib.sourceforge.net/ as net/sf/antcontrib/antcontrib.properties contains only tasks for ant versions before Ant 1.6.x
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With