Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

[Ant]Iterate over Tokens

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello:

In a ant buildfile, I have a property with strings separated with commas:

Now I want iterate over these tokens to execute some task. It would be like use String.split() Or use <forToken> JSTL tag. Exemple:

But I did nothing about this in Web. Comeone knows how to do this?

Thank,
 
author & internet detective
Posts: 39586
781
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rafael,
You can't do it in pure Ant. Instead, you can use an embedded scripting language like BSF (very similar to Java) to do the split. Then invoke a real Ant task with each of the classes.
 
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can, <foreach> from ant-contrib is exactly created for this comma seperated list.
 
Roseanne Zhang
Ranch Hand
Posts: 1953
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
foreach is a great task!
 
Jeanne Boyarsky
author & internet detective
Posts: 39586
781
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good to know. Gotta write that one down!
 
Rafael Afonso
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello:

Thanks to all. I have did this using javascript:

I did not know about ant-contrib. I will look at this.

thanks
 
He does not suffer fools gladly. But this tiny ad does:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!