java - How to make gradle use correct JDK when compiling? -


we use gradle build our java projects, based on jdk7 , on jdk8. know of org.gradle.java.home property, seems flawed me.

if configure in '~/.gradle/gradle.properties' force me use same jdk gradle projects.

if configure in '/my-git-project/gradle.properties' force me put reference local jdk installation in shared git repository. path jdk not belong there.

what would have similar in '~/.gradle/gradle.properties':

systemprop.jdk8=/my/local/path/to/jdk8 systemprop.jdk7=/my/local/path/to/jdk7 

and under source control in '/my-git-project/gradle.properties':

org.gradle.java.home=$systemprop.jdk8 

what's best solution/workaround this?

this more of process question gradle or java question. ultimately, have force specify various java_homes without being onerous. have several options:

  1. command line: ./gradlew -dorg.gradle.java.home=/path_to_jdk_directory

but, of course, has type hideous junk command line every time run build.

  1. gradle.properties , check-in path. then, make use same path.

not everyone's going want use same path, if have mac/unix , pc users.

2b. instead of using identical path, modify local gradle.properties custom values, never check-in modifications.

primary problem: someone's totally going check-in local values , screw ci , else.

  1. gradle.properties.template check-in, creates own gradle.properties; put gradle.properties in .gitignore

this might best bet. have template file check-in, has copy gradle.properties , fill in specific values. you'll need setup ci similar, or check-in gradle.ci.properties , have ci use that. but, has once instead of once per build. unfortunately, have update personal file every time template changes (unless write code that).


Comments