Search code examples
gradlejavac

Gradle - set specific JAVA_HOME for a specific project


Due to different servers running different JVM version. I would like to set a specific project to specific JDK version. I'm thinking may be setting JAVA_HOME with a task which compilation depends on it, but I'm not sure how to code it yet. But then there may be a simple setting I can do in build.gradle for that!?


Solution

  • I think you are after sourceCompatibilityand targetCompatibility. Settings those on a project has - as far as compilation is concerned - the same effect than -source and -target parameters to javac. If you need different settings for different compile tasks in one project, even that would be possible.