diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 08eadd0cfab..dd1459418d0 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -459,6 +459,8 @@ class BuildPlugin implements Plugin { // also apply release flag to groovy, which is used in build-tools project.tasks.withType(GroovyCompile) { final JavaVersion targetCompatibilityVersion = JavaVersion.toVersion(it.targetCompatibility) + options.fork = true + options.forkOptions.javaHome = new File(project.compilerJavaHome) options.compilerArgs << '--release' << targetCompatibilityVersion.majorVersion } }