fix for building on java 11 and above

nicksrules
Nick Brown 2023-07-12 11:12:20 -04:00
parent 54c84e7ca7
commit fcd9c7bf64
Signed by: bicknrown
GPG Key ID: 47AF495B3DCCE9C3
1 changed files with 27 additions and 0 deletions

View File

@ -111,6 +111,33 @@ object astral extends Module
def ivyDeps = Agg(
ivy"org.apache.spark::spark-sql::3.4.1",
)
def internalJavaVersion = T {
try {
val jvm = System.getProperties().getProperty("java.version")
println(f"Running Vizier with `${jvm}`")
jvm.split("\\.")(0).toInt
} catch {
case _:NumberFormatException | _:ArrayIndexOutOfBoundsException =>
println("Unable to retrieve java version. Guessing 11+")
11
}
}
def forkArgs = T {
if(internalJavaVersion() >= 11){
Seq(
// Required on Java 11+ for Arrow compatibility
// per: https://spark.apache.org/docs/latest/index.html
"-Dio.netty.tryReflectionSetAccessible=true",
// Required for Spark on java 11+
// per: https://stackoverflow.com/questions/72230174/java-17-solution-for-spark-java-lang-noclassdeffounderror-could-not-initializ
"--add-exports", "java.base/sun.nio.ch=ALL-UNNAMED",
"--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED",
)
} else { Seq[String]() }
}
}
}
}