Skip to content

Commit 734df98

Browse files
committed
Setting java boot classpath so that scala 2.10 works on gradle 7.2 (elastic#1800)
Gradle 7.2 broke scala 2.10 compilation. The problem seems to be that the java boot classpath jars are no longer getting into the scala boot classpath. This commit sets it in two ways: (1) it is explicitly set it in scalaCompileOptions.additionalParameters (to prevent the build from failing) and (2) it is set in options.bootstrapClasspath to prevent warnings from javac that its boot classpath is incompatible with the source version.
1 parent 0b8446d commit 734df98

File tree

5 files changed

+9
-1
lines changed

5 files changed

+9
-1
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

spark/core/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ tasks.named("test").configure {
150150

151151
// Set minimum compatibility and java home for compiler task
152152
tasks.withType(ScalaCompile) { ScalaCompile task ->
153+
task.scalaCompileOptions.additionalParameters = ["-javabootclasspath", new File(project.ext.runtimeJavaHome, 'jre/lib/rt.jar').absolutePath]
154+
task.options.bootstrapClasspath = layout.files(new File(project.ext.runtimeJavaHome, 'jre/lib/rt.jar'))
153155
task.sourceCompatibility = project.ext.minimumRuntimeVersion
154156
task.targetCompatibility = project.ext.minimumRuntimeVersion
155157
task.options.forkOptions.executable = new File(project.ext.runtimeJavaHome, 'bin/java').absolutePath

spark/sql-13/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ configurations.matching { it.name.contains('CompilerPlugin') == false }.all { Co
169169
}
170170

171171
tasks.withType(ScalaCompile) { ScalaCompile task ->
172+
task.scalaCompileOptions.additionalParameters = ["-javabootclasspath", new File(project.ext.runtimeJavaHome, 'jre/lib/rt.jar').absolutePath]
173+
task.options.bootstrapClasspath = layout.files(new File(project.ext.runtimeJavaHome, 'jre/lib/rt.jar'))
172174
task.sourceCompatibility = project.ext.minimumRuntimeVersion
173175
task.targetCompatibility = project.ext.minimumRuntimeVersion
174176
task.options.forkOptions.executable = new File(project.ext.runtimeJavaHome, 'bin/java').absolutePath

spark/sql-20/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ configurations.matching{ it.name.contains('CompilerPlugin') == false }.all { Con
189189
}
190190

191191
tasks.withType(ScalaCompile) { ScalaCompile task ->
192+
task.scalaCompileOptions.additionalParameters = ["-javabootclasspath", new File(project.ext.runtimeJavaHome, 'jre/lib/rt.jar').absolutePath]
193+
task.options.bootstrapClasspath = layout.files(new File(project.ext.runtimeJavaHome, 'jre/lib/rt.jar'))
192194
task.sourceCompatibility = project.ext.minimumRuntimeVersion
193195
task.targetCompatibility = project.ext.minimumRuntimeVersion
194196
task.options.forkOptions.executable = new File(project.ext.runtimeJavaHome, 'bin/java').absolutePath

spark/sql-30/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ configurations.matching{ it.name.contains('CompilerPlugin') == false }.all { Con
172172
}
173173

174174
tasks.withType(ScalaCompile) { ScalaCompile task ->
175+
task.scalaCompileOptions.additionalParameters = ["-javabootclasspath", new File(project.ext.runtimeJavaHome, 'jre/lib/rt.jar').absolutePath]
176+
task.options.bootstrapClasspath = layout.files(new File(project.ext.runtimeJavaHome, 'jre/lib/rt.jar'))
175177
task.sourceCompatibility = project.ext.minimumRuntimeVersion
176178
task.targetCompatibility = project.ext.minimumRuntimeVersion
177179
task.options.forkOptions.executable = new File(project.ext.runtimeJavaHome, 'bin/java').absolutePath

0 commit comments

Comments
 (0)