Skip to content

Commit fb32f4a

Browse files
authored
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.
1 parent 8544a32 commit fb32f4a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/groovy/com/google/protobuf/gradle/GenerateProtoTask.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import org.gradle.api.provider.Property
5050
import org.gradle.api.provider.Provider
5151
import org.gradle.api.provider.ProviderFactory
5252
import org.gradle.api.tasks.CacheableTask
53+
import org.gradle.api.tasks.IgnoreEmptyDirectories
5354
import org.gradle.api.tasks.Input
5455
import org.gradle.api.tasks.InputFiles
5556
import org.gradle.api.tasks.Internal
@@ -302,8 +303,9 @@ public abstract class GenerateProtoTask extends DefaultTask {
302303
}
303304

304305
@SkipWhenEmpty
305-
@InputFiles
306306
@PathSensitive(PathSensitivity.RELATIVE)
307+
@IgnoreEmptyDirectories
308+
@InputFiles
307309
FileCollection getSourceFiles() {
308310
return sourceFiles
309311
}

0 commit comments

Comments
 (0)