Filtering *only* test resources

Hi,

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

http://mrhaki.blogspot.co.uk/2010/11/gradle-goodness-add-filtering-to.html

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 {
        it.configure({
            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:

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)
  }

Excellent, thank you.

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

Ta.

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

ta. :slight_smile: