Gradle way of processing resources with maven notation


(suman jakkula) #1

I have few maven resource property files with ${} notation. I am working on migrating this project to gradle. processTestResources task is not replacing the values in ${}. Based on googling this is because gradle is using ant token identification which expects ‘@…@’ syntax.

How do we process resources in maven token format? i.e ${}

Is there any out-of-the box solution or should I have to write a custom processor?


(suman jakkula) #2

I was able to do it thru ugly hack.

configure(tasks.processTestResources) {
    include '**/*.properties'
    filter(ReplaceTokens,
            tokens: ['$':'={'], beginToken : '=', endToken : '{')
    filter(ReplaceTokens,
            tokens: [project.properties], beginToken : '{', endToken : '}')
}

#3

You can try using the built-in ‘expand’ support that uses the Groovy SimpleTemplateEngine: http://www.gradle.org/docs/current/userguide/working_with_files.html#N111EF

Or you can use the Ant ‘ExpandProperties’ filter, as described at http://stackoverflow.com/questions/7276368/how-can-i-get-ant-behavior-when-expanding-properties-with…