Does Gradle support configuring default file exclusions?


(David M. Carr) #1

I’m looking for a way to globally exclude files with certain extensions from being included in processing by Gradle. Example extensions that I’d like ignored are “.rej" and ".orig” (generated by Mercurial), or “*.bak” (generated by some text editors). I would like any files that match the configured pattern to be excluded from all tasks that support an exclusion pattern. So, for example, src/main/resources/someFile.orig would not be included as a resource in an assembled jar, and src/main/java/SomeFile.java.orig would not be considered for processing by license-gradle-plugin.

Ant supports this sort of concept using the defaultexcludes task.


(Peter Niederwieser) #2

The closest you can get is to declare excludes for source (directory) sets. Then anyone using those will be affected by the excludes. For example:

[sourceSets.all.java, sourceSets.all.resources].each {
     it*.exclude "**/*.rej"
 }

Note that Gradle supports the same standard excludes as Ant.