Task creating zip file containing a single empty directory is always considered up-to-date

I am trying to create a Zip file that contains a single empty direcctory with a Zip task. The result is that no Zip file is created, because the task is always considered ‘up-to-date’.

Am I doing something wrong here? Or is this a bug?

I use the following task, where the direcctory “dirContainingEmptyDir” contains a single empty directory:

task zipDirContainingEmptyDir(type: Zip) {
 from('/dirContainingEmptyDir')
 baseName = 'zipThatShouldContainEmptyDir'
 includeEmptyDirs = true
}

Hello Henning, the reason why the task is considered up-to-date is, that there is nothing to copy. Your task declaration copies everything IN the ‘/dirContainingEmptyDir’ directory, not the directory itself.

cheers, René

Hi Rene, yes, the directory ‘/dirContainingEmptyDir’ itself should not be zipped- but all contents of ‘/dirContainingEmptyDir’ should be zipped. But if the only contents is an empty directory, then this content is not zipped.

To clarify, in my example I have the following files: - /dirContainingEmptyDir [directory] - /dirContainingEmptyDir/emptyDir [directory]

Now I would expect that the task creates a Zip file that contains the directory ‘emptyDir’ - but this does not happen because the task is considered up-to-date.

If I add a file ‘test.txt’ to the directory ‘dirContainingEmptyDir’, then everything is fine (the resulting Zip file then contains both the file ‘test.txt’ and the empty directory ‘emptyDir’).

Cheers, Henning

understood. I mixed things up here. Looks like a bug to me. I’ve raised GRADLE-2827 for that.

cheers, René

OK, thanks!

Cheers, Henning