From fb32f4acdc7cf8266832d3a642b060df4196f38b Mon Sep 17 00:00:00 2001 From: Stefan Wolf Date: Fri, 5 Nov 2021 19:30:59 +0100 Subject: [PATCH] Ignore empty directories for sources (#530) Empty directories should not matter for source files, so let's ignore them for up-to-date checks as well. This avoids two issues: * Right now, the task will be out-of-date when you add an empty directory to the source folder. There will also be a build cache miss if the only difference between the sources is an empty directory somewhere. * In Gradle 8.0, the task won't skip any more if there are only empty directories in the source folder and no actual files. That is because the behaviour for skipping when empty and up-to-date checking will be more consistent. --- .../com/google/protobuf/gradle/GenerateProtoTask.groovy | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy b/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy index cf4f606a..0cf3a714 100644 --- a/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy +++ b/src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy @@ -50,6 +50,7 @@ import org.gradle.api.provider.Property import org.gradle.api.provider.Provider import org.gradle.api.provider.ProviderFactory import org.gradle.api.tasks.CacheableTask +import org.gradle.api.tasks.IgnoreEmptyDirectories import org.gradle.api.tasks.Input import org.gradle.api.tasks.InputFiles import org.gradle.api.tasks.Internal @@ -302,8 +303,9 @@ public abstract class GenerateProtoTask extends DefaultTask { } @SkipWhenEmpty - @InputFiles @PathSensitive(PathSensitivity.RELATIVE) + @IgnoreEmptyDirectories + @InputFiles FileCollection getSourceFiles() { return sourceFiles }