You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Pawanraj Sadhwani <pa...@elitecore.com> on 2004/05/05 09:21:00 UTC

If in MacroDef?

Hi,

I have a set of tasks repeating in the build file. uptil ant 1.5 i was using
the antcall with a parameter passed to a common task i had written.

In case of that target, i was using a if="foo" to allow for conditional
execution.

can similar thing be achieved using a macro? I refactored the common task
into a macro. now, when i call the macro, i would like an 'if' for the
execution. how to do it?

code snippet is:

<target name="do-all">
  <antcall target="do1" />
  <antcall target="do2" />
</target>

<target name="do1" if="do1.present">
  <antcall target="commondo">
    <param name="foo" value="1" />
  </antcall>
</target>

<target name="do2" if="do2.present">
  <antcall target="commondo">
    <param name="foo" value="2" />
  </antcall>
</target>

I could achieve what i want to by keeping antcalls in do-all and using macro
in do1 and do2.

However, I have a lot of antcalls in do-all which i dont like. Is it
possible to use if in the macro so i could replace ant-calls in do-all
target?

Thanx

Pawan