我已经从git仓库下载了Etherium客户端Java库 web3j 。当我尝试编译源代码时,它会失败,因为某些源文件是使用UTF-8编码创建的,但是gradle采用了我的操作系统默认编码(Cp1250)。

C:\web3j\web3j-master>gradlew install

> Task :crypto:javadoc FAILED
C:\web3j\web3j-master\crypto\src\main\java\org\web3j\crypto\Sign.java:102: error: unmappable character for encoding Cp1250
    //        routine specified in Section 2.3.7, where mlen = Ôî?(log2 p)/8Ôîë or mlen = Ôî?m/8Ôîë.
                                                                 ^
C:\web3j\web3j-master\crypto\src\main\java\org\web3j\crypto\Sign.java:102: error: unmappable character for encoding Cp1250
    //        routine specified in Section 2.3.7, where mlen = Ôî?(log2 p)/8Ôîë or mlen = Ôî?m/8Ôîë.

^
2 errors

如何强制gradle采用UTF-8编码而不是操作系统默认编码?

最佳答案

apply plugin: "java"
tasks.withType(JavaCompile) {
  options.encoding = "UTF-8"
}

08-26 17:36