Gradle java build fails with "cannot find symbol: Charset.defaultCharset()" with Google GuavaGWT 14.0-rc1

I see defaultCharset() method is present in java.nio.charset.Charset since Java 1.5, so it should be found by Gradle. I tried JDK 1.6 and 1.7 and the compilation worked on some machines, but failed on the others. uninstalling all JDKs and installing 1.7.0_u10 helped on one machine, but not on the others. this looks like a race condition bug in Gradle java plugin.

I tried both

apply plugin: ‘java’

sourceCompatibility = 1.6

and

apply plugin: ‘java’

sourceCompatibility = 1.7

in my multi-module GWT project.

error message:

error: cannot find symbol: Files.write(sb.toString(), sourceFile, Charset.defaultCharset());

symbol:

method defaultCharset()

location: class Charset

tried deleting “.gradle” folder - didn’t help.

I’m using Windows 7, JDK 1.6 and 1.7, Gradle 1.3 command-line. the compilation works fine in IDEA 12 with Gradle plugin.

UPDATE: I see the build works with

compile group: ‘com.google.guava’, name: ‘guava-gwt’, version: ‘12.0’ but fails with

compile group: ‘com.google.guava’, name: ‘guava-gwt’, version: ‘14.0-rc1’

it turns out guava-gwt library includes its own copy of java.nio.charset.Charset class, which does NOT have defaultCharset() method.