ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cyril Sagan" <Cyril.Sa...@sas.com>
Subject RE: replace an entry in a zip file?
Date Thu, 14 Jun 2007 16:11:44 GMT
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:Tanguy.RADEMAKERS@swift.com] 
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: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message