How to automatically output Unicode characters in Java property files using Gradle?

I translated a Java application using a ResourceBundle with various *.properties files. Now I like to have a Gradle task or want to change the task to automatically exit any Unicode character, replacing it with my ASCII representation, something like a Java native2ascii .

This is what I have done so far with my build file, but the output is not saved :

 import org.apache.tools.ant.filters.EscapeUnicode tasks.withType(ProcessResources) { filesMatching('**/*.properties') { println "\t-> ${it}" filter EscapeUnicode } } 

Any help is appreciated.

+6
source share
1 answer

You can do this by specifying an additional copy specification for property files, as follows:

 import org.apache.tools.ant.filters.EscapeUnicode tasks.withType(ProcessResources).each { task -> task.from(task.getSource()) { include '**/*.properties' filter(EscapeUnicode) } } 
+4
source

All Articles