You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Jon Skeet <jo...@peramon.com> on 2001/06/11 14:24:43 UTC

[PATCH] Allow update in zip task (and subtasks)

Functionality:
    The Zip task now allows users to specify that they wish to update an
existing file rather than creating a new one.

Configuration:
    The "update" property is a simple boolean, defaulting to false.

Implementation:
    If update is requested (and the zip file currently exists) we rename
it to a temporary file, add the specified files in the normal way,
keeping track of what we added, then add the contents of the temporary
file back in, excluding any files added.

Platform:
    This should work with JDK1.1 and higher.

Caveats:
    We keep track of added files in zipFile(InputStream in,
ZipOutputStream zOut, String vPath, long lastModified). If subclasses
override this (or add files in a different way, or override execute and
don't call the original), the functionality will either be lost or
broken. (Lost if they override execute), broken if they don't call
zipFile.) Further, the list of added files is kept as an instance
variable - if a single instance is used in two threads at the same time,
there could be problems. However, there would already be problems due to
addedDirs not being thread-safe either. (It wasn't cleared on cleanup,
either, which I've fixed.) Oh, and a general caveat that this is only my
second change to Ant, so could do with a lot of testing and
code-checking just in case I've misunderstood something and/or been
stupid.

Documentation:
    Haven't updated anything yet; zip.html should be changed - what
about subclasses such as Jar?

Diff: (using diff -uw Zip.java.original Zip.java, please tell me if
that's not correct)
    (See attached file - I didn't want to risk Exchange wrapping it...)

Please let me know if you try this out - both good and bad experiences
are welcome :)

Jon

Re: [PATCH] Allow update in zip task (and subtasks)

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 11 Jun 2001, Jon Skeet <jo...@peramon.com> wrote:

> Documentation:
>     Haven't updated anything yet; zip.html should be changed - what
> about subclasses such as Jar?

Yes, jar.html, ear.htmal and war.html should be changed as well.

Want to do it?

Stefan