ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <peterrei...@apache.org>
Subject Re: Strange behavior of 'zip'
Date Thu, 09 Dec 2004 12:24:18 GMT
I do not see the behaviour you describe:
  <target name="test">
    <delete file="newfile.zip" quiet="yes"/>
    <touch file="file1"/>
    <touch file="file2"/>
    <touch file="file3"/>
    <zip
      destfile="newfile.zip"
      whenempty="create"
      duplicate="fail"
      update="false">
      <fileset dir="." includes="file3"/>
    </zip>
    <ac:shellscript shell="bash">
      jar tf newfile.zip
    </ac:shellscript>
    <zip
      destfile="newfile.zip"
      whenempty="create"
      duplicate="fail"
      update="false">
      <fileset dir="." includes="file1"/>
    </zip>
    <ac:shellscript shell="bash">
      jar tf newfile.zip
    </ac:shellscript>
    <!-- I expects newfile.zip only contains file1 -->
    <zip
      destfile="newfile.zip"
      whenempty="create"
      duplicate="fail"
      update="true">
      <fileset dir="." includes="file2"/>
    </zip>
    <ac:shellscript shell="bash">
      jar tf newfile.zip
    </ac:shellscript>
    <!-- I expects newfile.zip contains file1, file2 -->
  </target>

the output is:
test:
   [delete] Deleting: /home/preilly/learning/a/zip/newfile.zip
      [zip] Building zip: /home/preilly/learning/a/zip/newfile.zip
[ac:shellscript] file3
      [zip] Building zip: /home/preilly/learning/a/zip/newfile.zip
[ac:shellscript] file1
      [zip] Updating zip: /home/preilly/learning/a/zip/newfile.zip
[ac:shellscript] file2
[ac:shellscript] file1

Peter

Yves Martin wrote:

>   Hello,
>
> I find the behavior of 'zip' strange when writing my build.xml. So I extracted
> a test case:
>
><?xml version="1.0"?>
><project name="test" default="test">
>
>  <target name="test">
>    <zip
>      destfile="newfile.zip"
>      whenempty="create"
>      duplicate="fail"
>      update="false">
>      <fileset dir="." includes="file1"/>
>    </zip>
>    <!-- I expects newfile.zip only contains file1 -->
>    <zip
>      destfile="newfile.zip"
>      whenempty="create"
>      duplicate="fail"
>      update="true">
>      <fileset dir="." includes="file2"/>
>    </zip>
>    <!-- I expects newfile.zip contains file1, file2 -->
>  </target>
></project>
>
>  What is the problem ?  
>
>  If newfile.zip already exists with 'file3' inside, 'file3' remains because
>  'zip' seems to work in 'append' mode only. 
>
>  And there is no way to make it create a new empty zip file if the destfile
>  already exists.
>
>  OK, I will do a 'delete' first. It is a work-around.
>
>  But I may find it useful to document this behavior and maybe to add a flag to
>  force new zip file creation.
>
> Regards,
>  
>


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


Mime
View raw message