File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes [Ant]Iterate over Tokens Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Reply Bookmark "[Ant]Iterate over Tokens" Watch "[Ant]Iterate over Tokens" New topic
Author

[Ant]Iterate over Tokens

Rafael Afonso
Ranch Hand

Joined: Jul 16, 2002
Posts: 63
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,


=================================<br /> Rafael U. C. Afonso<br /> <a href="http://www.javafree.com.br" target="_blank" rel="nofollow">www.javafree.com.br</a><br />=================================<br /><i>Where is debug?<br />debug is on the table</i>
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26192
    
  66

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
Yes, you can, <foreach> from ant-contrib is exactly created for this comma seperated list.
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
http://sourceforge.net/projects/ant-contrib
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
foreach is a great task!


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26192
    
  66

Good to know. Gotta write that one down!
Rafael Afonso
Ranch Hand

Joined: Jul 16, 2002
Posts: 63
Hello:

Thanks to all. I have did this using javascript:

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

thanks
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: [Ant]Iterate over Tokens
 
Similar Threads
Echoing all the environment properties
Ant build - what are 'iterate' and jtp file ?
First Bean with Database
wsjspc ant task
What is other way to iterate throgh collection instead of logic:iterate...?