Skip to content

Commit 92a0b0a

Browse files
authored
Stop forking groovyc (#30471)
This is a follow-up to our previous change to only fork javac if needed to respect the Java compiler home (via JAVA_HOME). This commit makes the same change for groovyc: we only fork groovyc if the JDK for Gradle is not the JDK specified for the compiler (via JAVA_HOME).
1 parent ee6abef commit 92a0b0a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

+9-4
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,15 @@ class BuildPlugin implements Plugin<Project> {
535535
}
536536
// also apply release flag to groovy, which is used in build-tools
537537
project.tasks.withType(GroovyCompile) {
538-
final JavaVersion targetCompatibilityVersion = JavaVersion.toVersion(it.targetCompatibility)
539-
options.fork = true
540-
options.forkOptions.javaHome = new File(project.compilerJavaHome)
541-
options.compilerArgs << '--release' << targetCompatibilityVersion.majorVersion
538+
final compilerJavaHomeFile = new File(project.compilerJavaHome)
539+
// we only fork if the Gradle JDK is not the same as the compiler JDK
540+
if (compilerJavaHomeFile.canonicalPath == Jvm.current().javaHome.canonicalPath) {
541+
options.fork = false
542+
} else {
543+
options.fork = true
544+
options.forkOptions.javaHome = compilerJavaHomeFile
545+
options.compilerArgs << '--release' << JavaVersion.toVersion(it.targetCompatibility).majorVersion
546+
}
542547
}
543548
}
544549
}

0 commit comments

Comments
 (0)