that's weird, i'm using 1.6.5 as well. 

I think we have a misunderstanding.

Here's what i did:

1) make three files a.txt, b.txt, c.txt, each with some text

2) create the following build.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project name="bollo" default="testzip" basedir=".">
    <target name="testzip">
        <zip destfile="txtfiles.zip" update="true">
            <fileset dir="." includes="*.txt"/>
        </zip>
    </target>
</project>

3) run that to get the first zip file: txtfiles.zip, containing the
three txt files listed above.

4) move b.txt and c.txt to b.bak and c.bak (so the zip task no longer
sees them) and update a.txt (add a string "updated")

5) re-run the build, and the updated zip archive txtfiles.zip now
contains the original versions of b.txt and c.txt, but the updated
version of a.txt.

In my book, that's equivalent to "replace one entry in a zip file with
an updated file", no?

/t

>-----Original Message-----
>From: Cyril Sagan [mailto:[EMAIL PROTECTED] 
>Sent: Thursday, June 14, 2007 6:12 PM
>To: Ant Users List
>Subject: RE: replace an entry in a zip file?
>
>Thanks for your reponse.  However, this does not work for me 
>in Ant 1.6.5.
>Note that my goal is to *replace* a file that's already in the zip.
>
>Seems like the best solution would be for the duplicate 
>attribute to support a "replace" option.
>
>FWIW, I'm doing this to control my jar manifest.  I can't use 
><jar> because Ant merges with its default manifest.  I'm 
>having a hard time employing this advice from the Ant doc:
>
>http://ant.apache.org/manual/CoreTasks/manifest.html
>
>    If you find that Ant generates manifests incompatible with your
>    runtime, take a manifest it has built, fix it up however you need
>    and switch to using the <zip>  task to create the JAR, feeding in
>    the hand-crafted manifest.
>
>Here's my build.xml:
>
><?xml version="1.0"?>
><project name="manifest_test" default="go">
>
>    <target name="go">
>        <!-- build trivial sample jar -->    
>        <mkdir dir="work" />
>        <touch file="work/a" />
>        <touch file="work/b" />
>
>        <jar jarfile="test.jar" update="true">
>            <fileset dir="work" includes="**/*" />
>        </jar>
>
>        <!-- Use zip to add my manifest without having Ant -->
>        <!-- try to merge with its default one, that is:   -->
>        <!-- main/org/apache/tools/ant/defaultManifest.mf  -->
>        <zip destfile="test.jar" basedir="work" update="true">
>            <zipfileset dir="." includes="my_manifest"
>                                fullpath="META-INF/MANIFEST.MF"/>
>        </zip>
>    </target>
></project>
>
>Thanks.
>
>--Cyril
>
>
>-----Original Message-----
>From: RADEMAKERS Tanguy [mailto:[EMAIL PROTECTED] 
>Sent: Thursday, June 14, 2007 5:23 AM
>To: Ant Users List
>Subject: RE: replace an entry in a zip file?
>
>Hello Cyril,
>
>>GOAL:  To replace one entry in a zip file with an updated file.
>>
>>I cannot find an elegant way to do this, short of <unzip>'ing the 
>>archive, replacing the file of interest and then re-<zip>.  It seems 
>>there should be a better way.  Can anyone help?
>>
>>Thanks.
>>
>>--Cyril
>
>If you use the update attribute of the zip task - it will 
>"refresh" the zip with the file or files you send it, without 
>changing or removing the other files in the archive. You may 
>still need to extract the files of interest from the zip if 
>you don't have them elsewhere, but you don't need to explode 
>the whole zip just to change a few files.
>
>Regs,
>/t
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED] For 
>additional commands, e-mail: [EMAIL PROTECTED]
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to