ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@bost.de>
Subject Re: Specifying repeated tasks: loops, sub-tasks, ...?
Date Mon, 04 Sep 2000 13:49:23 GMT
>>>>> "BK" == Bill Kelly <bill.kelly@softwired-inc.com> writes:

 BK> Has the list ever discussed making it easier to do repeated
 BK> actions, or specify many similar sub-tasks using loops or
 BK> sub-tasks or some existing feature I've missed?

Yes and no. Procedural logic has been ruled out several times - but
you are going to find that <ant> could help you out here.

Don't define the property named test.class anywhere:

<target name="wrapped.test">
  <delete file="file1"/>
  <delete file="file2"/>
  <java classname="${test.class}" />
  <delete file="file1"/>
  <delete file="file2"/>
</target>

<target name="tests">
  <ant dir="." antfile="${ant.file}" target="wrapped.test">
    <property name="test.class" value="test1" />
  </ant>
  <ant dir="." antfile="${ant.file}" target="wrapped.test">
    <property name="test.class" value="test2" />
  </ant>
  <ant dir="." antfile="${ant.file}" target="wrapped.test">
    <property name="test.class" value="test3" />
  </ant>
</target>

So "procedure calls" are already supported.

Be aware that you are going to pay a high price for it speaking of
resources, you are going to instantiate a new project and reparse
build.xml for each call. Once ${} expansion happens at execution time
this overhead can be dropped easily.

What's missing now is the loop construct if you don't want to retype
the stuff all over and over again. You could use the <script> task or
write your own Java task to get this.

Somewhat of topic:

 BK> The JUnit task provides its own solution to this, but again in a
 BK> very specific way.

The task you are referring is different from the one in the Ant
distribution, do you think we could merge some useful features from it
with the version in Ant's current CVS tree.

Stefan

Mime
View raw message