• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How do one call an ant macrodef from inside a groovy script?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want 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>
 
Bob Saenger
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Thank you very much for your example, I was looking for something like this.
I'm trying to use javascript instead of groovy (i don't know groovy at all) and i get an error when setting my attribute.
error is pretty basic info: Unknown attribute

to be honest i think it should work, but i was just don't know if you know if this setDynamicAttribute also works with javascript? or will it only work for groovy?
 
Why does your bag say "bombs"? The reason I ask is that my bag says "tiny ads" and it has stuff like this:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic