Gradle uses java6 compiler even with source compatability 1.7

Hi,

We are using gradle 1.12 for our java build. The problem is that in a particular machine, the build breaks, since gradle seems to use the java 6 compiler. The logs are shown below:

Gist link of the build failure: https://gist.github.com/anonymous/62c99d6f87b398a58f66

By default, Gradle will compile with the same JDK that Gradle itself is run with, so perhaps that machine has JDK6 on its ‘PATH’, or has ‘JAVA_HOME’ pointing to JDK6. ‘gradle -v’ will tell.

PS: ‘jdk6.Jdk6JavaCompiler’ in the stack trace doesn’t mean that Gradle is compiling with JDK6. It just means that it is using the compiler API introduced in JDK6.

I should add that ‘sourceCompatibility’ doesn’t have any effect on which compiler/runtime library will be used. It just determines the language level used by the compiler.

Thank you for the quick response. However, when we do print out the version of the JVM on the command prompt and JAVA_HOME, it all points to JDK 7. Furthermore, JDK 6 is not even installed in the system. See below Gist: https://gist.github.com/anonymous/0aa9d69431ebfb7415d8

We’re pretty sure that whatever logs we have would not be sufficient to figure out the cause, but we appreciate the help nevertheless. In any case, is there a way that we can print out on the console the actual java command run by the build - that might throw up some pointers as to where the issue lies.

What counts is the Java version printed by ‘gradle -v’. If this prints “1.7.0” under “JVM”, then unless you’ve reconfigured ‘compileJava.options.forkOptions.executable’, JDK7 will be used for compilation. (If you’ve set ‘compileJava.options.fork = true’ or ‘compileJava.options.useAnt = true’, try to set both to ‘false’.) Running with ‘–info’ should print out the equivalent ‘javac’ command, however what’s really used is the Java compiler API.

Thank you - that should be fine to try and get to the root cause.