Skip files from TemplateEngine in processResources


(Philipp Meier) #1

The project has resource *.yml files with multiline strings values which contain SimpleTemplateEngine-like placeholders ${placeholder}. When the processResources task is being executed the expand fails because it can not do the template processing.
Is there a way to just skip this template processing in FilterChain or processResources for certain files?


(Philipp Meier) #2

I found an answer myself:

    processResources {
        filesMatching("**/*.yml") { matchedFile ->
            filter { line ->
                line.replace('${', '\\${')
            }
        }
    }

Escape the placeholders in the *.yml to prevent Gradle’s template expanding to throw MissingPropertyException because these placeholders are later used from the application to parametrize dynamically.