[GRADLE-2827] Copy tasks incorrectly consider themselves up to date when a new empty directory is added to source and ignoreEmptyDirs = false Created: 05/Jul/13  Updated: 10/Feb/17  Resolved: 10/Feb/17

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Gradle Forums Assignee: Lari Hotari
Resolution: Won't Fix Votes: 1


 Description   

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
}



 Comments   
Comment by Gradle Forums [ 05/Jul/13 ]

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é

Comment by Gradle Forums [ 05/Jul/13 ]

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

Comment by Lari Hotari [ 09/Oct/15 ]

appears to be fixed by https://github.com/gradle/gradle/commit/db753ed6 and https://github.com/gradle/gradle/commit/afcbb6a9 , will investigate later

Comment by Lari Hotari [ 03/Nov/15 ]

I checked if the changes for Gradle 2.9 would make this work. There is no change for Gradle 2.9 . What made me think that this could be fixed was this issue referenced in the source code, in a test that started failing after I made the changes I mentioned in my previous comment.

Comment by Lari Hotari [ 03/Nov/15 ]

I checked if it would be possible to override the getSource method of the AbstractCopyTask class. That has the annotation "SkipWhenEmpty". However it's not possible to prevent using that annotation in a subclass because of the behaviour in AnnotationProcessingTaskFactory.Validator.attachActions, which always scans all annotations of superclasses regardless if the method was overridden in a subclass.

Comment by Lari Hotari [ 03/Nov/15 ]

There is a workaround in https://discuss.gradle.org/t/up-to-date-for-empty-inputs/9967/2

Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Benjamin Muschko [ 10/Feb/17 ]

Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved.

Generated at Wed Jun 30 12:32:35 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.