Skip to content

Commit d5bf03e

Browse files
masseykemark-vieira
authored andcommitted
Builds with java 17 (#1802)
This commit adds support for building on java 17, while leaving support for building java 11 untouched.
1 parent 2ee175a commit d5bf03e

File tree

7 files changed

+49
-6
lines changed

7 files changed

+49
-6
lines changed

hive/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ dependencies {
5858
javadocSources(project(":elasticsearch-hadoop-mr"))
5959
}
6060

61+
tasks.named("test").configure {
62+
onlyIf { JavaVersion.current() >= JavaVersion.VERSION_16 }
63+
jvmArgs "--add-opens=java.base/java.io=ALL-UNNAMED" // Needed for IOUtils's BYTE_ARRAY_BUFFER reflection
64+
jvmArgs "--add-opens=java.base/java.net=ALL-UNNAMED" // Needed for org.apache.hadoop.hive.common.StringInternUtils
65+
}
66+
6167
jar {
6268
dependsOn(project.configurations.embedded)
6369
from(project.configurations.embedded.collect { it.isDirectory() ? it : zipTree(it)}) {

pig/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ dependencies {
4747
javadocSources(project(":elasticsearch-hadoop-mr"))
4848
}
4949

50+
tasks.named("test").configure {
51+
onlyIf { JavaVersion.current() >= JavaVersion.VERSION_16 }
52+
jvmArgs "--add-opens=java.base/java.io=ALL-UNNAMED" // Needed for IOUtils's BYTE_ARRAY_BUFFER reflection
53+
}
54+
5055
jar {
5156
dependsOn(project.configurations.embedded)
5257
from(project.configurations.embedded.collect { it.isDirectory() ? it : zipTree(it)}) {

spark/core/build.gradle

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ sparkVariants {
2626
project.getTasks().getByName(scalaCompileTaskName) { ScalaCompile compileScala ->
2727
configure(compileScala.scalaCompileOptions.forkOptions) {
2828
memoryMaximumSize = '1g'
29-
jvmArgs = ['-XX:MaxPermSize=512m']
3029
}
3130
compileScala.scalaCompileOptions.additionalParameters = [
3231
"-feature",
@@ -143,8 +142,14 @@ configurations.matching{ it.name.contains('CompilerPlugin') == false }.all { Con
143142
conf.exclude group: "org.mortbay.jetty"
144143
}
145144

146-
tasks.named("test").configure {
147-
jvmArgs "--add-opens=java.base/java.io=ALL-UNNAMED" // Needed for IOUtils's BYTE_ARRAY_BUFFER reflection
145+
if (JavaVersion.current() >= JavaVersion.VERSION_17) {
146+
tasks.withType(Test) { Test task ->
147+
if (task.getName().startsWith("test"))
148+
task.configure {
149+
jvmArgs "--add-opens=java.base/java.io=ALL-UNNAMED" // Needed for IOUtils's BYTE_ARRAY_BUFFER reflection
150+
jvmArgs "--add-opens=java.base/java.nio=ALL-UNNAMED" // Needed for org.apache.spark.SparkConf, which indirectly uses java.nio.DirectByteBuffer
151+
}
152+
}
148153
}
149154

150155
// Set minimum compatibility and java home for compiler task

spark/sql-13/build.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ sparkVariants {
3636
project.getTasks().getByName(scalaCompileTaskName) { ScalaCompile compileScala ->
3737
configure(compileScala.scalaCompileOptions.forkOptions) {
3838
memoryMaximumSize = '1g'
39-
jvmArgs = ['-XX:MaxPermSize=512m']
4039
}
4140
compileScala.scalaCompileOptions.additionalParameters = [
4241
"-feature",
@@ -174,6 +173,14 @@ tasks.withType(ScalaCompile) { ScalaCompile task ->
174173
task.options.forkOptions.executable = new File(project.ext.runtimeJavaHome, 'bin/java').absolutePath
175174
}
176175

176+
if (JavaVersion.current() >= JavaVersion.VERSION_16) {
177+
tasks.withType(Test) { Test task ->
178+
if (task.getName().startsWith("test"))
179+
task.configure {
180+
jvmArgs "--add-opens=java.base/java.io=ALL-UNNAMED" // Needed for IOUtils's BYTE_ARRAY_BUFFER reflection
181+
}}
182+
}
183+
177184
// Embed the embedded dependencies in the final jar after all configuration is complete
178185
sparkVariants {
179186
all { SparkVariantPlugin.SparkVariant variant ->

spark/sql-20/build.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ sparkVariants {
3232
project.getTasks().getByName(scalaCompileTaskName) { ScalaCompile compileScala ->
3333
configure(compileScala.scalaCompileOptions.forkOptions) {
3434
memoryMaximumSize = '1g'
35-
jvmArgs = ['-XX:MaxPermSize=512m']
3635
}
3736
compileScala.scalaCompileOptions.additionalParameters = [
3837
"-feature",
@@ -194,6 +193,14 @@ tasks.withType(ScalaCompile) { ScalaCompile task ->
194193
task.options.forkOptions.executable = new File(project.ext.runtimeJavaHome, 'bin/java').absolutePath
195194
}
196195

196+
if (JavaVersion.current() >= JavaVersion.VERSION_16) {
197+
tasks.withType(Test) { Test task ->
198+
if (task.getName().startsWith("test"))
199+
task.configure {
200+
jvmArgs "--add-opens=java.base/java.io=ALL-UNNAMED" // Needed for IOUtils's BYTE_ARRAY_BUFFER reflection
201+
}}
202+
}
203+
197204
// Embed the embedded dependencies in the final jar after all configuration is complete
198205
sparkVariants {
199206
all { SparkVariantPlugin.SparkVariant variant ->

spark/sql-30/build.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ sparkVariants {
3030
project.getTasks().getByName(scalaCompileTaskName) { ScalaCompile compileScala ->
3131
configure(compileScala.scalaCompileOptions.forkOptions) {
3232
memoryMaximumSize = '1g'
33-
jvmArgs = ['-XX:MaxPermSize=512m']
3433
}
3534
compileScala.scalaCompileOptions.additionalParameters = [
3635
"-feature",
@@ -177,6 +176,15 @@ tasks.withType(ScalaCompile) { ScalaCompile task ->
177176
task.options.forkOptions.executable = new File(project.ext.runtimeJavaHome, 'bin/java').absolutePath
178177
}
179178

179+
if (JavaVersion.current() >= JavaVersion.VERSION_16) {
180+
tasks.withType(Test) { Test task ->
181+
if (task.getName().startsWith("test"))
182+
task.configure {
183+
jvmArgs "--add-opens=java.base/java.io=ALL-UNNAMED" // Needed for IOUtils's BYTE_ARRAY_BUFFER reflection
184+
jvmArgs "--add-opens=java.base/java.nio=ALL-UNNAMED" // Needed for org.apache.spark.SparkConf, which indirectly uses java.nio.DirectByteBuffer
185+
}}
186+
}
187+
180188
// Embed the embedded dependencies in the final jar after all configuration is complete
181189
sparkVariants {
182190
all { SparkVariantPlugin.SparkVariant variant ->

test/shared/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ configurations {
5858
}
5959
}
6060

61+
tasks.named("test").configure {
62+
onlyIf { JavaVersion.current() >= JavaVersion.VERSION_16 }
63+
jvmArgs "--add-opens=java.base/java.io=ALL-UNNAMED" // Needed for IOUtils's BYTE_ARRAY_BUFFER reflection
64+
}
65+
6166
dependencies {
6267
api(project(':elasticsearch-hadoop-mr'))
6368
api(project.ext.hadoopClient) {

0 commit comments

Comments
 (0)