Filtering *only* test resources

(David Harrigan) #1


I’m trying to filter only test resources in each subproject. I have followed this example:

replacing the “all” with * as necessary in the latest gradle versions and slighly adapted to this:

afterEvaluate {
    def processResourcesTasks = sourceSets*.processResourcesTaskName.collect { tasks[it] }
      processResourcesTasks.each {
            filter(ReplaceTokens, tokens: testProperties)

However, this filters all resources in java and also in test. How would I go about restricting this to only filter resources in my src/main/resources folder?

Thank you! :slight_smile:

(Peter Niederwieser) #2

Since you are talking about test resources, I assume you want to filter ‘src/test/resources’. That’s as simple as:

processTestResources {
  filter(ReplaceTokens, tokens: testProperties)

(David Harrigan) #3

Excellent, thank you.

Just one last thing I suppose, if I define the processTestResources, does it replace (or append) other processTestResource(s) in subprojects?


(Peter Niederwieser) #4

To apply this configuration to all subprojects, wrap it with ‘subprojects { … }’. Or ‘allprojects’, if the current project is to be included as well.

(David Harrigan) #5

ta. :slight_smile: