I am working on a project where we use a templating system to produce build-specific files.
It works by taking a file with the keyword .template
somewhere in the name, processing it, and then outputting it to the filename it would have if the keyword was removed.
However, this seems to work bad with gradle. If i let the extension be xml, i get (as expected) errors explaining that my XML is not parseable, which makes sense as it has the templating syntax in it.
If i make the file end with .template
, i get errors complaining that the file has to end with .xml
:
:app:mergeDebugResources
[...]android/app/src/main/res/values/colors.xml.template: Error:The file name must end with .xml
:app:mergeDebugResources FAILED
I have tried excluding it in the grade build file, like this:
Android Studio: Exclude resource file under resources sourceSets
but to no avail.
I tried doing this in the android block of my build.gradle:
packagingOptions {
exclude '*.template'
}
Without it doing anything.
I found a few other posts about doing similar things on the internet yesterday, but they all did it differently in some way, and some of them were many years old.
Therefore, my question is, what is the easiest/best way to exclude all files containing .template
at any position in the file name? For my exact issue, the file lies in the resources folder, but a general, one size fits all solution would be great