Appending zip file tree to another zip file tree but the files are not updating


(Ramesh Pasham) #1

Appending the zip content to another zip content. Issue is that the files are not updating in the resulted zip. Please help us how to solve this one in gradle our code : task archiveDist(type: Zip) {

baseName = ‘Cordys BOP’

extension = ‘zip’

version = ‘4.2.8’

FileTree fullzip = zipTree(‘Cordys BOP 4.2 CU1.zip’)

FileTree hotfixzip = zipTree(‘FixPack_Cordys_D1.002.007_Windows.zip’)

from(fullzip,hotfixzip) }

//in ant

we can do using update attribute in zip task

<zip destfile="${dist.dir}/cumulative/FixPack_Cordys_${product.version}_${os-type}.zip"

update=“true” whenempty=“fail”>


(Peter Niederwieser) #2

Issue is that the files are not updating in the resulted zip.

Can you elaborate?

PS: Please use HTML code tags for code snippets.


(Ramesh Pasham) #3

Hi Peter, Assume we have two zips have same files but in one zip has old file and another zip has latest file. If we append the second zip to first zip, the file is not overwriting just adding as another file.

src1.zip contains A.txt, B.txt src2.zip contains A.txt, C.txt When i add these two zips

dest.zip contains A.txt A.txt B.txt C.txt

here A.txt not overwriting just adding as another file.


(Peter Niederwieser) #4

It’s a known limitation of the ‘Zip’ task that it will always add both files, without a way to customize the behavior. If you need to overwrite files, you can either unzip to a temporary directory, or use the Ant task.


(Ramesh Pasham) #5

Thanks Peter for your quick reply. Then we opt for ant zip in gradle. It also solves our requirement.