gradle.properties in user home: org.gradle.java.home=C:/Java/jdk1.8.0_72 (we have to use 8 as of some plugins we use)
build.gradle: sourceCompatibility = 1.7 targetCompatibility = 1.7
So gradle runs with a JDK 8 and supposed to build with compatibility 7. At least that’s what we thought. Now if you use a Method from a java8 api like list.sort(..) the build won’t crash although I use the targets 1.7
you are only setting sourceCompatibility and targetCompatibility but you are still compiling with Java 8. You would need to set the bootClasspath on CompileOptions to a Java 7 JDK, too.
Another option would be to compile with a Java 7 javac like described in the userguide for Java 6. Note that this has quite a performance impact since Gradle will not be able to reuse the compiler daemons.
I’m sorry but I fail to see in the userguide what command-line parameters should I pass to gradle to use JDK8 for itself, while using JDK7 to perform the compilation. Would you please show the command line example here?