Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem: how to call an ant macrodef from inside a groovy script

Status
Not open for further replies.

meinc

Programmer
Oct 21, 2005
2
DE
I need to use an ant macrodef inside of an ant script,
simplified I want to do something as follows.
Is this possible? Where can I found more about the
Ant+Groovy Syntax, or better what can be used from ant
inside the script element.

<macrodef name="mymacro">
<attribute name="myparam"/>
<sequential>
<echo message="@{myparam}"/>
</sequential>
</macrodef>

<target name="script" >
<script language="groovy">

mymacro.setMyParam( <computed by script> )

mymacro.execute() // does not work

mymacro.perform() // does not work either

</script>
</target>
 
had a nice weekend,
found the solution myself

it works as follows:

<macrodef name="x" >
<attribute name="msg"/>
<sequential>
<echo message="@{msg}"/>
</sequential>
</macrodef>

<target name="script" >
<script language="groovy"><![CDATA[
t = project.createTask("x")
t.setDynamicAttribute("msg", "Heurerka!")
t.perform()
]]></script>
</target>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top