如何使用Gradle自动转义Java属性文件中的unicode字符?

Chr*_*del 6 java unicode gradle properties-file

我正在使用各种文件来翻译Java应用程序.现在我想要一个Gradle任务,或者想要修改一个任务,通过将其替换为ASCII表示来自动转义任何unicode字符,就像Java的工具一样.ResourceBundle*.propertiesnative2ascii

这是我到目前为止使用我的构建文件所做的,但输出仍未转义:

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

tasks.withType(ProcessResources) {
    filesMatching('**/*.properties') {
        println "\t-> ${it}"
        filter EscapeUnicode
    }
}
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏.

Sta*_*lav 5

您可以通过以下方式为属性文件提供附加的复制规范:

import org.apache.tools.ant.filters.EscapeUnicode
tasks.withType(ProcessResources).each { task ->
    task.from(task.getSource()) {
        include '**/*.properties'
        filter(EscapeUnicode)
    }
}
Run Code Online (Sandbox Code Playgroud)