New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow ignoring empty directories in task inputs #2463
Comments
I think it could make sense for this to be the default behavior with maybe a way to opt into "directories are meaningful" if there's a use case for it. I think As an example, I think we should consider:
and
as identical. It could be easy for people to get build cache misses without an obvious cause otherwise. |
@wolfs I'd like to try and fix this, is that ok? I'd be making it so that |
Oh my B, this is the wrong issue. I meant #2016. Either way, I'd like to fix all the input inconsistencies. 😁 |
Is this issue also about empty source roots? For example, if you have two builds, and in one of those builds an empty root:
there will be a cache miss if the task involved has multiple source roots. For example, |
I have seen this issue impact users without their having any awareness of it. It is apparently not uncommon to have empty source directories in a project. Because git will not commit an empty directory, only some users will have an empty dir, leading to relocatability issues that impact the remote build cache. Here is how this situation typically arises, in my experience:
In either case, Proposal: Gradle ignore empty source directories by default. Is there a use-case for considering them? Do empty directories ever carry semantic meaning? |
As an addendum, sometimes people do something like the below to detect empty source dirs and fail the build in their presence. Unfortunately, this has the side effect of making every
|
Yes, this happens quite often. I would estimate that this is happening in every non-trivial project with more than one developer and a version control system. This can also happen the following case: |
This is happening to us with great frequency and makes using the build cache correctly a challenge. Configuring custom task inputs with If there's no fix for this problem forthcoming, can the documentation be updated to reflect this fact? Can |
As temporary workaround if you are using git, you could add following git hook - #!/bin/sh
set -e
find . -type d -empty -not -path "./.git/*" -not -path "*/build/*" -not -path "./.idea/*" -not -path "*/.gradle/*" -delete |
These cause cache misses such as with the `MergeResources` task in the Android Gradle Plugin. Workaround for Gradle treating empty directories as unique: gradle/gradle#2463
FYI that Kotlin kapt in 1.4.0 appears to leave empty source directories: https://youtrack.jetbrains.com/issue/KT-41353 |
When an empty source directory is found, fail the build. Empty source directories cause cache misses. Ref gradle#2463
These cause cache misses and slow down the build. We need to dogfood this issue so we are motivated to fix it. Follow up from gradle#14407 If you are reading this, please vote this up: gradle#2463
This has been fixed in 6.8 RC1. |
See e.g. this forum request: https://discuss.gradle.org/t/build-cache-issue-how-to-exclude-empty-directories-from-compile/22820
It would be good to be able to declare that an input property does not care about empty directories but only about files. We already do this automatically for classpath resources.
The use case described in the forum is Java source files which also makes good sense.
The text was updated successfully, but these errors were encountered: