I'd love to filter specific java resources in my gradle project. Where some files should have replaced contents only, some should be also renamed (and have different content replaced).
My gradle java project setup is:
> cat build.gradle
apply plugin: 'java'
sourceSets {
main {
java {
resources {
srcDirs = [ "foo" ]
include '**/**'
}
}
}
}
processResources {
include '**/file_a.txt'
filter { String line ->
line
.replace("foo", "fool" )
}
}
processResources {
include '**/file_b.txt'
rename { "file_c.txt" }
filter { String line ->
line
.replace("ipsum", "zzz" )
}
}
> cat foo/file_a.txt
my name is foo
test ipsum
> cat foo/file_b.txt
lorem ipsum ...
Once running:
gradle build
I get:
> ls build/resources/main
file_c.txt
> cat build/resources/main/file_c.txt
my name is fool
test zzz
However I'd like to get both files, where only file_b.txt
would be renamed and both would be replaced by the specific rules. What is the proper way to achieve that?