Much ado about scripting, Linux & Eclipse: card subject to change

2008-12-08

Obfuscation 101: Ant-contrib

I have recently fallen in love with ant-contrib. I'd still rather write Bash scripts, but if one must interact w/ Ant, ant-contrib is the only way to survive it. Without it, you don't have variables, for-loops, or if-elseif-then trees.

Of course, with every love there are moments of extreme angst. For example, I've been fighting with this error for the last 12 hrs, on and off, as I've been trying to resolve bug 256440:

Invalid type class org.apache.tools.ant.TaskAdapter used in For task, it does not have a public iterator method

What does that mean? It means I'm a dumbass.

Though I should know better, I rely on tools such as Eclipse's Ant editor to tell me when I've messed up task syntax. And though it can do CTRL-SPACE completion for the <for> task, the editor doesn't mark this invalid (if I've already typed it in).

<for ...>
 <if>
   ...
 </if>
</for>

The fix?

<for ...>
 <sequential>
   <if>
     ...
   </if>
 </sequential>
</for>

Ultimately, though, I wish error messages would be written with the end-user in mind. The above problem would have been solved in seconds had it been simply "For task cannot contain nested If task... dumbass." :)

4 comments:

Unknown said...

Thanks dude

Anton said...

Holy shit! Thank God for you - I've been hitting my head against the wall for hours. I can finally use if statements nested in for loops. My life has meaning once more!!!!

Mader Levap said...

It is well known fact that all framework programmes (*cough* JBoss, seam *cough*) have clause in contracts that specifically demands as useless error messages and exceptions as possible.

More seriously, this helped in my problem too. Thanks!

Capricorn1 said...

Dumbass or not, your blog post solved my issue. I'm fixing a build script that someone else wrote. They checked in a change to it late last night. They must not have checked to make sure that last-minute change actually worked. All the other for loops had the sequential tag .. except the one that failed.