Copying files from one JAR to another using ANT
To avoid needless duplication of source files in two different repositories, I would like to write an Ant build.xml file that copies files from one .jar file to another. I don’t want to copy everything in the source jar, just certain selected files.
Now I could certainly use the unjar task to extract everything from the jar into a temporary directory, then use a copy
task to copy the files to the directory from which the new jar will be built, then use a delete task to remove the temporary directory. However is there anything simpler?
In particular, is there a way to treat a jar (or, for that matter, a zip or a tar) as a directory tree from which files can be copied without making temporary copies first? For instance, could I set the src
attribute of the copydir
element to a jar file instead of an actual directory?
July 7th, 2006 at 10:03 AM
(http://ant.apache.org/manual/CoreTypes/zipfileset.html) is your friend!
July 7th, 2006 at 12:18 PM
Use (http://ant.apache.org/manual/CoreTypes/zipfileset.html).
July 7th, 2006 at 2:00 PM
Is anything wrong with ZipFileSet for your needs? (http://ant.apache.org/manual/CoreTypes/zipfileset.html)
If that does not work out, maybe a FileSet adapter can be created on top of the TrueZip library: https://truezip.dev.java.net/
July 7th, 2006 at 10:24 PM
I think you’re looking for the
zipfileset
element on thezip
task, and presumably alsojar
.