对于gradle2.0以前的版本,在build.gradle的最后加上
tasks.withType(Compile) {
options.encoding = "UTF-8"
}
对于gradle2.0以后的版本,在build.gradle的最后加上
tasks.withType(JavaCompile) { options.encoding = "UTF-8" }
Compile 已经被重命名为 JavaCompile
.
要设置 Groovy sources, 使用tasks.withType(GroovyCompile) { groovyOptions.encoding = "UTF-8" }
.
设置Scala sources, 使用tasks.withType(ScalaCompile) { scalaCompileOptions.encoding = "UTF-8" }
.