Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unzipping jars 'where they stand'

 
Righteous Raven
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this unzip syntax.
Rene
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Righteous Raven
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmmm... I guess this means I'll be writing my own class... <sigh>
Thanks,
RighteousRaven
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic