You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Alejandro Abdelnur <al...@sun.com> on 2001/09/02 04:14:33 UTC

[PATCH] ant1.4B2 added support for *DEFAULT* target

i've modified the executeTarget method of the org.apache.tools.ant.Project class to support
a *DEFAULT* target if a nonexisting target is called, similar to the switch's default.

if the invoked target is not defined in the build file and the "*DEFAULT*" target is
defined, then the "*default*" target is executed, the name of the missing target is stored
in the "target.name" property.

for example:

   <target name="*DEFAULT*" depends="init">
        <echo message="Missing target [${target.name}] delegating to custom.xml"/>
        <ant antfile="custom.xml" target="${target.name}"/>
    </target>

attached you'll find the modified Project.java file.

regards.

a


Re: [PATCH] ant1.4B2 - antcall task, added support for looping

Posted by Stefan Bodewig <bo...@apache.org>.
looping has been rejected in the Ant2 process, see the "Simple Flow
Control" section in <http://jakarta.apache.org/ant/ant2/features.html>
for some reasons.

Several implementations of a foreach task (that would be superior to
an iterating <antcall>) have been sent to this list, but they'll never
make it into the core (probably) - writing one that uses the
TaskContainer infrastructure of Ant 1.4 should be straight forward.

Stefan

[PATCH] ant1.4B2 - antcall task, added support for looping

Posted by Alejandro Abdelnur <al...@sun.com>.
i've modified the the org.apache.tools.ant.CallTarget class to support iterations.

it allows to execute the antcall task in a looping way. the iterate
attribute contains the list (space separated) to iterate through, the
iterator attribute defines the name of the property that will contain
the element of the current iteration (the looping variable). for example:

    <target name="buildModule" if="module">
        <echo message="building module ${module}"/>
        ...
    </target>

    <target name="build">
        <property name="modules" value="frontend backend reporting"/>

        <antcall target="buildModule"
              iterate="${modules}" iterator="module" />
    </target>

the antcall task will invoke the buildModule target 3 times, each time
the value of the iterator variable -module- will be set to "frontend",
"backend" and "reporting".


attached you'll find the modified CallTarget.java file.

regards.

a