This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
hey, I need to unzip a whole bunch of jars which are contained within a directory tree, but I want to preserve the location of the jars, as well as the structure of the files within the jars. For example, say i have 2 jars: /a/b/first.jar and /a/c/second.jar now i want to unzip them such that the contents of first.jar end up in /a/b/ while the contents of second.jar end up in /a/c/. (note that 2 separate zip commands doesnt work, cause in reality i have 100 jars) The command: <unzip> <fileset dir="/a" /> </unzip> doesnt work because it would extract the contents of both first.jar and second.jar to the /a/ directory. One solution is to have a class that recursively searches through the directory tree and executes its body on every dir that matches a patternset.. but i dont know if that exists or not. Any suggestions? THANKS!! -RighteousRaven
Standard Ant doesn't provide any loop syntax, and rightfully so. It's not meant to be a programming language. However, much of the need for looping would be reduced if you could take a fileset or patternset and have a task act on each member individually ... maybe by using an antcall. Sometimes the tasks you want don't support filesets, and sometimes (as with unjar) they interpret them differently from what you need. The bad news is I can't think of anyway to do accomplish this in the current Ant. However, we've identified a gap that could conceivably be filled. Some day, I'm going to learn how to develop Ant tasks on my own. In the meantime, you could try submitting your idea to the Ant team.
Ah, but the point is not to unjar a single jar file in place, but to unjar all the jar files in a fileset, with different destinations as determined by where the jar is found. As another example, I run Castor to convert a series of XML schemas (XSD files) to classes. I've written a parameterized task that executes the Castor compiler:
I can call this target with antcall:
However, every time I add a new schema, I have to go into the build.xml and write another antcall task. It would be nice if I could just find all the XSD files in the schema directory and run Castor on them. Of course, I'd still need a way to derive the package name to use, but I think that would be possible. My point is that often it would be nice to execute a target individually on each of the files in a fileset. Right now, I can't think of any way to do that.
Joined: Apr 24, 2003
hmmm... I guess this means I'll be writing my own class... <sigh> Thanks, RighteousRaven