You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Steve Molloy <sm...@convera.com> on 2005/03/23 16:58:19 UTC
Args in goals
Hi,
Does anyone know if there are plans to allow passing arguments when
calling goals? For instance, I have to run the same goal for each item
in a list. It would be nice to be able to pass the item as argument and
get some result back, similar to a jelly invoke call... Something like:
<j:forEach var="curItem" items="${myList}">
<attainGoal name="myGoal" var="theResult">
<arg type="java.lang.Object" value="${curItem}"/>
</attainGoal>
<echo>Current item: ${theResult}</echo>
</j:forEach>
...
<goal name="myGoal" returns="java.lang.String">
<param type="java.lang.Object" name="theItem"/>
<j:invoke on="theItem" method="toString" var="return"/>
</goal>
But more useful. <<smiley-4.png>> .. ;-)
Thanks,
Steve
Re: Args in goals
Posted by Erik Husby <mh...@broad.mit.edu>.
Steve Molloy wrote:
>Hi,
>
> Does anyone know if there are plans to allow passing arguments when
>calling goals? For instance, I have to run the same goal for each item
>in a list. It would be nice to be able to pass the item as argument and
>get some result back, similar to a jelly invoke call... Something like:
>
><j:forEach var="curItem" items="${myList}">
> <attainGoal name="myGoal" var="theResult">
> <arg type="java.lang.Object" value="${curItem}"/>
> </attainGoal>
> <echo>Current item: ${theResult}</echo>
></j:forEach>
>
>...
>
><goal name="myGoal" returns="java.lang.String">
> <param type="java.lang.Object" name="theItem"/>
> <j:invoke on="theItem" method="toString" var="return"/>
></goal>
>
>But more useful. <<smiley-4.png>> .. ;-)
>
>Thanks,
>Steve
>
>
>
>
Don't use a goal, create a new tag.
<define:taglib uri="mytags">
<define:tag name="myOperation">
<... whatever tasks you need to do...>
</define:tag>
</define:taglib>
<mytags:myOperation theItem="theItemValue"/>
Parameter passing is unstructured, untyped. In the above, in the
definition of "myOperation" one would refer to the parameter as a Jelly
expression, i.e. "${theItem}"
Examine the sources of some of the plugins for more details.
--
Erik Husby
Senior Software Engineer
Broad Institute of MIT and Harvard
Rm. 2192 320 Charles St, Cambridge, MA 02141-2023
mobile: 781.354.6669, office: 617.258.9227,
email: mhusby@broad.mit.edu AIM: ErikAtBroad
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org