Trying to list the directory contents in a <fileset>
Mike London
Ranch Hand
Joined: Jul 12, 2002
Posts: 949
posted
0
Hello,
I'm trying to get ant to (at first) list the directory contents using the ant <fileset> task.
Here's what I have so far...
Eventually, after I'm actually able to list all the files in the filedir, I'll want to call a Java program to compress them (remove whitespace and comments from JS and CSS files).
I've tried adding an Echo command, but get the error that nested commands aren't supported.
How do I actually print out the directory listing, file by file, inside a task that uses the Fileset task/tag?
Once I'm able to process each file, then presumably I could use the java task to call a jar file to actually do something with each file?
I do not know of any Ant task that will print out the contents of a fileset. But why bother doing that? Why not simply use the copy task with your fileset and a filterchain using the deletecharacters, striplinebreaks, etc.
You could use the <pathconvert> task, as is explained in this weblog.
It demonstrates how to convert a <path> definition to a pretty printable string, but the same approach should work for a <fileset>, since <pathconvert>'s refid attribute accepts a reference to either a <path>, <fileset>, <dirset>, or <filelist> according to the documentation.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Mike London
Ranch Hand
Joined: Jul 12, 2002
Posts: 949
posted
0
What I'm actually trying to do is this...
During the build task, I want to compress the JavaScript and CSS using the Yahoo tools.
Our javascript and css folders in the Java project (Eclipse) have about 10 files each.
And, the added complication is that the compression utility only takes one file at a time, no wildcards.
Is there a better way to process directories so that I call a compression utility with a javascript file as input and write the compressed output to another folder?
A batch file and an "Exec" sounds like it wouldn't be cross-platform.
Ideas would be appreciated.
Thanks again!!!
- M
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: Trying to list the directory contents in a <fileset>