ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject antcall and dynamic properties
Date Thu, 14 Sep 2000 16:15:11 GMT

I've tried to rewrite CallTarget to take advantage of the fact, that
properties get evaluated at runtime, by not instantiating a new
Project but simply setting the properties to a new value temporarily.

I'm facing a problem here and I'm not quite sure how to proceed.

Before Target executes a Task it calls Task.maybeConfigure. If this
task hasn't been configured already (i.e. the setter methods haven't
been called) it does so now - otherwise this is a no op.

I've implemented it this way so that you could change the attributes
of a task after it has been run and rerun the target (using <script>
for example) later using that new value by executing the target again.
If maybeConfigure would call the setters again, the values set in
between would be overwritten.

On the other hand this means that ${} expansion happens once and only
once per task. If I'd use the approach to CallTarget described above

<target name="tocall">
  <echo message="${a}" />

<target name="call1">
  <antcall target="tocall">
    <param name="a" value="1" />

<target name="call2">
  <antcall target="tocall">
    <param name="a" value="1" />

<target name="main" depends="call1,call2" />

would produce 1 twice because call1 would call the setter method with
${a} translated to 1 and call2 wouldn't call the setter method at all
- because the echo task has been configured already.

So I only see two options, neither of which I really like:

1) keep everything as it is right now - creating a new project and
reparsing the build file for each antcall.

2) change maybeConfigure to always reevaluate the attributes -
breaking scripts and tasks that call Target.execute on targets that
have already been run.

Any other ideas?


View raw message