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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to