升级到Gradle 2.0后:无法在根项目上find属性“编译”

为了避免在构build我的Java源代码时遇到有关特殊字符的警告,我把这行代码放到了我的gradle.build ,在升级到Gradle 2.0之前,

 tasks.withType(Compile) { options.encoding = "UTF-8" } 

升级之后,失败并出现以下错误:

 Could not find property 'Compile' on root project 

我该如何解决这个问题?

将行更改为

 tasks.withType(JavaCompile) { options.encoding = "UTF-8" } 

解决了这个问题。

使用'task.withType(JavaComplie)'

– – – – – – – – – – – 矿 – – – – – – – – – – – – –

 buildscript { repositories { jcenter() } dependencies { classpath 'com.bmuschko:gradle-tomcat-plugin:2.2.3' } tasks.withType(JavaCompile) { options.debug = true options.debugOptions.debugLevel = "source,lines,vars" options.encoding = "UTF-8" } } 

对于基于Groovy的项目。 这将是:

 tasks.withType(GroovyCompile) { options.debug = true }