aboutsummaryrefslogtreecommitdiff
path: root/project
diff options
context:
space:
mode:
authorMarcelo Vanzin <vanzin@cloudera.com>2016-05-31 16:54:34 -0700
committerMarcelo Vanzin <vanzin@cloudera.com>2016-05-31 16:54:34 -0700
commit57adb77e6b0208dc6d29488a674b6ad78702262f (patch)
tree2de7dfa2f3b62bccc3a8417d1fba69db5cecf24f /project
parent90b11439b3d4540f48985e87dcc99749f0369287 (diff)
downloadspark-57adb77e6b0208dc6d29488a674b6ad78702262f.tar.gz
spark-57adb77e6b0208dc6d29488a674b6ad78702262f.tar.bz2
spark-57adb77e6b0208dc6d29488a674b6ad78702262f.zip
[SPARK-15451][BUILD] Use jdk7's rt.jar when available.
This helps with preventing jdk8-specific calls being checked in, because PR builders are running the compiler with the wrong settings. If the JAVA_7_HOME env variable is set, assume it points at a jdk7 and use its rt.jar when invoking javac. For zinc, just run it with jdk7, and disable it when building jdk8-specific code. A big note for sbt usage: adding the bootstrap options forces sbt to fork the compiler, and that disables incremental compilation. That means that it's really not convenient to use for normal development, but should be ok for automated builds. Tested with JAVA_HOME=jdk8 and JAVA_7_HOME=jdk7: - mvn + zinc - mvn sans zinc - sbt Verified that in all cases, jdk8-specific library calls fail to compile. Author: Marcelo Vanzin <vanzin@cloudera.com> Closes #13272 from vanzin/SPARK-15451.
Diffstat (limited to 'project')
-rw-r--r--project/SparkBuild.scala16
1 files changed, 14 insertions, 2 deletions
diff --git a/project/SparkBuild.scala b/project/SparkBuild.scala
index f08ca7001f..744f57c517 100644
--- a/project/SparkBuild.scala
+++ b/project/SparkBuild.scala
@@ -277,12 +277,24 @@ object SparkBuild extends PomBuild {
// additional discussion and explanation.
javacOptions in (Compile, compile) ++= Seq(
"-target", javacJVMVersion.value
- ),
+ ) ++ sys.env.get("JAVA_7_HOME").toSeq.flatMap { jdk7 =>
+ if (javacJVMVersion.value == "1.7") {
+ Seq("-bootclasspath", s"$jdk7/jre/lib/rt.jar")
+ } else {
+ Nil
+ }
+ },
scalacOptions in Compile ++= Seq(
s"-target:jvm-${scalacJVMVersion.value}",
"-sourcepath", (baseDirectory in ThisBuild).value.getAbsolutePath // Required for relative source links in scaladoc
- ),
+ ) ++ sys.env.get("JAVA_7_HOME").toSeq.flatMap { jdk7 =>
+ if (javacJVMVersion.value == "1.7") {
+ Seq("-javabootclasspath", s"$jdk7/jre/lib/rt.jar")
+ } else {
+ Nil
+ }
+ },
// Implements -Xfatal-warnings, ignoring deprecation warnings.
// Code snippet taken from https://issues.scala-lang.org/browse/SI-8410.