Skip to content

Commit

Permalink
Ignore empty directories for sources (#530)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wolfs authored Nov 5, 2021
1 parent 8544a32 commit fb32f4a
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -302,8 +303,9 @@ public abstract class GenerateProtoTask extends DefaultTask {
}

@SkipWhenEmpty
@InputFiles
@PathSensitive(PathSensitivity.RELATIVE)
@IgnoreEmptyDirectories
@InputFiles
FileCollection getSourceFiles() {
return sourceFiles
}
Expand Down

0 comments on commit fb32f4a

Please sign in to comment.