How build multiple projects with gradle with multiple jdk versions?

I have multiple projects and build using different jdks(IBM,SUN) and versions(1.6,1.7,1.8).

In my gradle script of the each project I have defined the sourceCompatibility and targetCompatibility. How can I define the each project specific org.gradle.java.home?

If I define the IBM jdk 6 as org.gradle.java.home in my main project gradle.properties file other projects build will fail.

I have gradle.properties file only main gradle project.

I don’t want to use JAVA_HOME class path variable to run my gradle scripts. I’m using gradle 2.4.

Please give some advice to fix this issue?

I have tried to add gradle.properties file in each project and try to override org.gradle.java.home. But that also couldn’t work.

You have to specify “javac” for the JavaCompile tasks, probably similar to what I do. If you apply the linked gradle script for a project and call, say configureJavaCompilers(6), it will use the javac specified in the jdk6Compiler properties (possibly definend in the global gradle.properties).