This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trying to list the directory contents in a <fileset>

 
Mike London
Ranch Hand
Posts: 1192
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Thanks in advance.

- M
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mike London
Ranch Hand
Posts: 1192
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic