You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by "Rosen, Alex" <ar...@silverstream.com> on 2000/12/05 21:07:10 UTC

Zips with arbitrary layout

Hi all.

I'm trying to use Ant to let our users build a ZIP/JAR file with an arbitrary
layout, putting any file anywhere in the archive they want. This is a superset
of the WAR functionality. For example, I'd like to be able to put all files
from c:\dev\classes\ into the archive at "web-inf/classes/", and all files from
c:\images\project4\ into "images/", and the file c:\props\proj4.properties into
"props/default.properties". I'd like to do this without copying files.

I spent a while writing code for this in the 1.2 tree, creating a class that I
called Zip2. Then I noticed a change to War.java, by Stefan about a month ago,
that does something similar. Cool.

However, I'd like to make a couple of suggestions:

- I think it would be nice if this facility were in Zip.java, rather than
War.java. Then, War could just be a special case of Zip - and all the J2EE
archves (WAR, EJB JAR, EAR, Client JAR) would work the same way. E.g. right now
it's not possible to create an EAR unless your deployment descriptor is named
"meta-inf/application.xml" (or you don't mind copying it to that filename).
This fix would let you create archives with any layout you wanted (EAR, WAR,
new formats defined in the future, etc), without having to create a new task.

- Another problem that keeps the above scenario from working is that the new
prefix mechanism in War doesn't support renaming of files. E.g. if my
deployment descriptor is named "proj4-ear.xml", I can't put it in the archive
as "meta-inf/application.xml". In my Zip2.java, filesets not only support an
"prefix" property (which I can "archivedir"), but also an "archivefile"
property. This is the full filename to save the file as. It is only valid if
the fileset represents a single file. E.g.

  <fileset dir="${src}" includes="proj4-ear.xml"
archivefile="meta-inf/application.xml" />

- The new War uses sub-elements named "prefixfileset" (rather than "fileset"),
which support the "prefix" property. I think it would be nice if you didn't
need to remember to use this special name, and could just use regular <fileset>
elements. (This can be fixed by just changing the method name
addPrefixedFileSet() to addFileSet().)

- There's currently no way to create a War that contains *only* prefixed files.
If you use only prefixfilesets, then it (Zip.java) thinks it has no filesets,
so it throws an error, even though War.java is perfectly happy.

Any opinions on these ideas? If people think this is a good idea, I'd be happy
to submit a patch.

Thanks!
Alex