Skip to content

Commit

Permalink
Fork Groovy compiler onto compile Java home
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jasontedor committed Jan 18, 2018
1 parent 4746d30 commit e192a11
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ class BuildPlugin implements Plugin<Project> {
// 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
}
}
Expand Down

0 comments on commit e192a11

Please sign in to comment.