ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Corley <davidcor...@gmail.com>
Subject Re: Dynamic macro dispatch.
Date Tue, 24 Mar 2009 13:17:32 GMT
Well the only reason I specified the method below is that you asked what
could be done with ant-core.
I don't think you can do much more than what I've suggested.
However, if you're able to use ant-contrib, then you can simplify it a
little more using the ant-contrib <if> task.
So:
<if>
<equals arg1="${x}" arg2="a"/>
<then>
<macroA/>
</then>
<elseif>
<equals arg1="${x}" arg2="b"/>
<then>
<macroB/>
 </then>
</elseif>
<elseif>
<equals arg1="${x}" arg2="c"/>
<then>
<macroC/>
 </then>
 </elseif>
</if>
As I said before, this all depends on whether you can use the ant-contrib
classes.
http://ant-contrib.sourceforge.net/

Regards,
Dave



On Tue, Mar 24, 2009 at 1:10 PM, Felix Dorner <FDorner@zed.com> wrote:

>
> This approach would make the macros obsolete. Instead I
> would move the macro code into the targets you mention, and could do
> <antcall target="${x}">
>
> This is actually how my build file currently looks like. But I
> want to switch to macros as they are more lightweight and controllable.
>
>
> Felix
>
> > You'd probably be better have individual properties as flags
> > for each macro.
> > So something like:
> > <condition property="flagA">
> > <equals arg1="${x} arg2="a"/>
> > </condition>
> > <condition property="flabB">
> > <equals arg1="${x} arg2="b"/>
> >  </condition>
> > <condition property="flagC">
> > <equals arg1="${x} arg2="c"/>
> >  </condition>
> > <target name="RunMacroA if="flagA">
> > <macroA/>
> > </target>
> > <target name="RunMacroB if="flagB">
> > <macroB/>
> >  </target>
> > <target name="RunMacroC if="flagC">
> > <macroC/>
> >  </target>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


-- 
"To be or not to be. That's not really a question." - Jean-Luc Godard

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message