Search code examples
gradleunicodeescapingproperties-file

gradle resource bundle properties EscapeUnicode: not working


Gradle escape resource bundle .properties

import org.apache.tools.ant.filters.EscapeUnicode

processResources {
   from '/path/resources'
   include '*.properties'
   filter (EscapeUnicode)
}

The escaped proeprties files are not correct. The properties file are in UTF-8 encoding. Need to specify

encoding="UTF-8"

? how to specify encoding for the filter?


Solution

  • The property you are after is filteringCharset. It defines the encoding of the files when filters are used. Without this setting the system default encoding is used, so you should always specify it when using filters.

    processResources {
        filteringCharset 'UTF-8'
    }