Groovy Ant Secrets


I was pondering about this earlier today. Wondering how I would invoke an Ant task that used nested text data using Groovy Ant. Why? Because I looked at the Ant script task while browsing Ant docs and said, “Hmm. that’d be neat to embed a script in a GroovyAnt build… but how do I pass text?” Well it just dawned on me that the random errors I’d been getting with Groovy’s AntBuilder exposed the answer. Occasionally I’ll forget to prefix a task attribute with an attribute name like:
ant.available(property:'menu.icon.found', '/menu.png', classpath:'target/MapQuestCoolStuff.jar')
And I’ll get an error saying:
ERR: SCRIPT FAILED: The type doesn't support nested text data ("/menu.png").
ERR: The type doesn't support nested text data ("/menu.png").

It’s telling me that the second parameter is being passed to AntBuilder as text instead of a task attribute.

2 thoughts on “Groovy Ant Secrets

  1. ahh i got this error replacing one of the colons with an equals
    ant.mail(from=”me”,…)
    instead of
    ant.mail(from:’me’,…)

  2. Yeah, it’s amazing how you can learn new features of a tool from a simple typ’o or finger fumble. Incidentally, that’s how I learned many of my IntelliJ Idea hot keys.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s