You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by sr...@apache.org on 2019/02/04 14:56:45 UTC

[spark] branch master updated: [SPARK-26813][BUILD] Consolidate java version across language compilers and build tools

This is an automated email from the ASF dual-hosted git repository.

srowen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 755f9c2  [SPARK-26813][BUILD] Consolidate java version across language compilers and build tools
755f9c2 is described below

commit 755f9c20761e3db900c6c2b202cd3d2c5bbfb7c0
Author: seancxmao <se...@gmail.com>
AuthorDate: Mon Feb 4 08:56:24 2019 -0600

    [SPARK-26813][BUILD] Consolidate java version across language compilers and build tools
    
    ## What changes were proposed in this pull request?
    The java version here means versions of javac source, javac target, scalac target. They could be consolidated as a single version (currently 1.8)
    
    |      |javac|scalac   |
    |------|-----|---------|
    |source|1.8  |2.12/2.11|
    |target|1.8  |1.8      |
    
    The current issues are as follows
    
    * Maven build defines a single property (`java.version`) to specify java version while SBT build defines different properties for javac (`javacJVMVersion`) and scalac (`scalacJVMVersion`). SBT build should use a single property as Maven build does.
    * Furthermore, it's better for SBT build to refer to `java.version` defined by Maven build. This is possible since we've already been using sbt-pom-reader.
    
    ## How was this patch tested?
    Tested locally.
    
    ```
    build/mvn clean compile
    build/sbt clean compile
    ```
    
    Closes #23724 from seancxmao/specify-java-version-once.
    
    Authored-by: seancxmao <se...@gmail.com>
    Signed-off-by: Sean Owen <se...@databricks.com>
---
 project/SparkBuild.scala | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/project/SparkBuild.scala b/project/SparkBuild.scala
index 65ba25c..659659f 100644
--- a/project/SparkBuild.scala
+++ b/project/SparkBuild.scala
@@ -76,8 +76,7 @@ object BuildCommons {
 
   val testTempDir = s"$sparkHome/target/tmp"
 
-  val javacJVMVersion = settingKey[String]("source and target JVM version for javac")
-  val scalacJVMVersion = settingKey[String]("source and target JVM version for scalac")
+  val javaVersion = settingKey[String]("source and target JVM version for javac and scalac")
 }
 
 object SparkBuild extends PomBuild {
@@ -240,23 +239,22 @@ object SparkBuild extends PomBuild {
       if (major >= 8) Seq("-Xdoclint:all", "-Xdoclint:-missing") else Seq.empty
     },
 
-    javacJVMVersion := "1.8",
-    scalacJVMVersion := "1.8",
+    javaVersion := SbtPomKeys.effectivePom.value.getProperties.get("java.version").asInstanceOf[String],
 
     javacOptions in Compile ++= Seq(
       "-encoding", "UTF-8",
-      "-source", javacJVMVersion.value
+      "-source", javaVersion.value
     ),
     // This -target and Xlint:unchecked options cannot be set in the Compile configuration scope since
     // `javadoc` doesn't play nicely with them; see https://github.com/sbt/sbt/issues/355#issuecomment-3817629
     // for additional discussion and explanation.
     javacOptions in (Compile, compile) ++= Seq(
-      "-target", javacJVMVersion.value,
+      "-target", javaVersion.value,
       "-Xlint:unchecked"
     ),
 
     scalacOptions in Compile ++= Seq(
-      s"-target:jvm-${scalacJVMVersion.value}",
+      s"-target:jvm-${javaVersion.value}",
       "-sourcepath", (baseDirectory in ThisBuild).value.getAbsolutePath  // Required for relative source links in scaladoc
     ),
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org