How to I conditionally filter a file during the "processResources" stage (1.7 warns of a duplicate file)


(Ramon Buckland) #1

Is there a way, during the processResources, to only apply the filter to “one” file.

Currently I have the following which works (see below) 1.6 was ok, 1.7-rc1 complains about a duplicate file (because I am effectively copying the file “twice”.

What I want (I assume I want) is to say

[[ during processResources, if the file is called “myproject.properties” then apply the filter. ]]

processResources {
  from("src/main/resources/myproject.properties") {
    filter { String line ->
      line.replaceAll(/\$\{applicationVersion\}/,version)
    }
  }
}

How do you achieve that ?


(Luke Daley) #2

In 1.7 you can use pattern based configuration.

http://www.gradle.org/docs/release-candidate/release-notes#pattern-based-file-copy-configuration


(Ramon Buckland) #3

Thanks Luke. That was spot on.