Zip task does not recognize binary/text files


(Ondřej Fafejta) #1

How can I create zip archive file with correct file flags? E.g. files .txt, README etc. have text flag other files have binary flag.

When I created test.zip archive file by gradle zip task all files are binary. (see example below - important is column with “b-”)

$ zipinfo build/test.zip

Archive: build/test.zip

Zip file size: 12866 bytes, number of entries: 3

-rw-r–r-- 2.0 unx

12 b- defN 13-Dec-27 21:35 test.txt

-rw-r–r-- 2.0 unx

12825 b- defN 13-Dec-27 21:35 test.pdf

-rw-r–r-- 2.0 unx

14 b- defN 13-Dec-27 21:35 README

I must call external command to achieve what I want. But this solution is platform dependent.

e.g.

task makeZip2(dependsOn: ‘copyFiles’) << {

exec {

workingDir = buildDir.absolutePath + “/test”

executable = “zip”

args = [’…/test.zip’, ‘*’]

standardOutput = new ByteArrayOutputStream()

}

}

$ zipinfo build/test.zip

Archive: build/test.zip

Zip file size: 13018 bytes, number of entries: 3

-rw-r–r-- 3.0 unx

12 tx stor 13-Dec-27 21:38 test.txt

-rw-r–r-- 3.0 unx

12825 bx defN 13-Dec-27 21:38 test.pdf

-rw-r–r-- 3.0 unx

14 tx stor 13-Dec-27 21:38 README

Is there some clean gradle solution there?

Thanks Ondrej Fafejta