在 Gradle 中正确显示 UTF-8 文本 [英] Show UTF-8 text properly in Gradle

查看:28
本文介绍了在 Gradle 中正确显示 UTF-8 文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个任务:

task info<<{
    println "Gradle — система автоматической сборки, построенная на принципах Apache Ant и Apache Maven, но предоставляющая DSL на языке Groovy вместо традиционной XML-образной формы представления конфигурации проекта."
}

当我使用命令时:

gradle info -Dfile.encoding=UTF-8

文本显示不正确.如何解决?谢谢.

The text is not shown properly. How to fix it? Thanks.

推荐答案

file.encoding 系统属性需要在 JVM 执行 Gradle 构建(例如 Gradle 守护程序)启动时正确设置.实现此目的的一种方法是使用 export GRADLE_OPTS="-Dfile.encoding=utf-8".另一种可行的方法是将 systemProp.file.encoding=utf-8 添加到 gradle.properties.当然,这假设构建脚本文件实际上使用的是 utf-8 编码.要查看您的平台(以及 Gradle)的默认编码是什么,请在构建脚本中打印出系统属性的值.

The file.encoding system property needs to be set right when the JVM executing the Gradle build (e.g. the Gradle Daemon) starts up. One way to achieve this is with export GRADLE_OPTS="-Dfile.encoding=utf-8". Another way that might work is to add systemProp.file.encoding=utf-8 to gradle.properties. Of course this assumes that the build script files are actually using utf-8 encoding. To see what your platform's (and therefore Gradle's) default encoding is, print out the system property's value in a build script.

这篇关于在 Gradle 中正确显示 UTF-8 文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆