Fork Groovy compiler onto compile Java home
We use the --release flag which is only available starting in JDK 9. Since Gradle could be running on JDK 8 without forking the compiler, compilation will occur with the Java home of Gradle. This commit adds a fork flag to the compiler Java home so that we use the right compiler. Relates #28300
This commit is contained in:
parent
66c81e7f5e
commit
4214a718ec
|
@ -459,6 +459,8 @@ class BuildPlugin implements Plugin<Project> {
|
||||||
// also apply release flag to groovy, which is used in build-tools
|
// also apply release flag to groovy, which is used in build-tools
|
||||||
project.tasks.withType(GroovyCompile) {
|
project.tasks.withType(GroovyCompile) {
|
||||||
final JavaVersion targetCompatibilityVersion = JavaVersion.toVersion(it.targetCompatibility)
|
final JavaVersion targetCompatibilityVersion = JavaVersion.toVersion(it.targetCompatibility)
|
||||||
|
options.fork = true
|
||||||
|
options.forkOptions.javaHome = new File(project.compilerJavaHome)
|
||||||
options.compilerArgs << '--release' << targetCompatibilityVersion.majorVersion
|
options.compilerArgs << '--release' << targetCompatibilityVersion.majorVersion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue