Skip to content

Commit 546683c

Browse files
da-liiisrowen
authored andcommitted
[SPARK-25298][BUILD] Improve build definition for Scala 2.12
## What changes were proposed in this pull request? Improve build for Scala 2.12. Current build for sbt fails on the subproject `repl`: ``` [info] Compiling 6 Scala sources to /Users/rendong/wdi/spark/repl/target/scala-2.12/classes... [error] /Users/rendong/wdi/spark/repl/scala-2.11/src/main/scala/org/apache/spark/repl/SparkILoopInterpreter.scala:80: overriding lazy value importableSymbolsWithRenames in class ImportHandler of type List[(this.intp.global.Symbol, this.intp.global.Name)]; [error] lazy value importableSymbolsWithRenames needs `override' modifier [error] lazy val importableSymbolsWithRenames: List[(Symbol, Name)] = { [error] ^ [warn] /Users/rendong/wdi/spark/repl/src/main/scala/org/apache/spark/repl/SparkILoop.scala:53: variable addedClasspath in class ILoop is deprecated (since 2.11.0): use reset, replay or require to update class path [warn] if (addedClasspath != "") { [warn] ^ [warn] /Users/rendong/wdi/spark/repl/src/main/scala/org/apache/spark/repl/SparkILoop.scala:54: variable addedClasspath in class ILoop is deprecated (since 2.11.0): use reset, replay or require to update class path [warn] settings.classpath append addedClasspath [warn] ^ [warn] two warnings found [error] one error found [error] (repl/compile:compileIncremental) Compilation failed [error] Total time: 93 s, completed 2018-9-3 10:07:26 ``` ## How was this patch tested? ``` ./dev/change-scala-version.sh 2.12 ## For Maven ./build/mvn -Pscala-2.12 [mvn commands] ## For SBT sbt -Dscala.version=2.12.6 ``` Closes apache#22310 from sadhen/SPARK-25298. Authored-by: Darcy Shen <[email protected]> Signed-off-by: Sean Owen <[email protected]>
1 parent 39d3d6c commit 546683c

File tree

5 files changed

+24
-12
lines changed

5 files changed

+24
-12
lines changed

docs/building-spark.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,19 @@ On Linux, this can be done by `sudo service docker start`.
256256
or
257257

258258
./build/sbt docker-integration-tests/test
259+
260+
## Change Scala Version
261+
262+
To build Spark using another supported Scala version, please change the major Scala version using (e.g. 2.12):
263+
264+
./dev/change-scala-version.sh 2.12
265+
266+
For Maven, please enable the profile (e.g. 2.12):
267+
268+
./build/mvn -Pscala-2.12 compile
269+
270+
For SBT, specify a complete scala version using (e.g. 2.12.6):
271+
272+
./build/sbt -Dscala.version=2.12.6
273+
274+
Otherwise, the sbt-pom-reader plugin will use the `scala.version` specified in the spark-parent pom.

project/SparkBuild.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ object SparkBuild extends PomBuild {
9494
case Some(v) =>
9595
v.split("(\\s+|,)").filterNot(_.isEmpty).map(_.trim.replaceAll("-P", "")).toSeq
9696
}
97+
98+
Option(System.getProperty("scala.version"))
99+
.filter(_.startsWith("2.12"))
100+
.foreach { versionString =>
101+
System.setProperty("scala-2.12", "true")
102+
}
97103
if (System.getProperty("scala-2.12") == "") {
98104
// To activate scala-2.10 profile, replace empty property value to non-empty value
99105
// in the same way as Maven which handles -Dname as -Dname=true before executes build process.

repl/pom.xml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232

3333
<properties>
3434
<sbt.project.name>repl</sbt.project.name>
35-
<extra.source.dir>scala-2.11/src/main/scala</extra.source.dir>
36-
<extra.testsource.dir>scala-2.11/src/test/scala</extra.testsource.dir>
35+
<extra.source.dir>src/main/scala-${scala.binary.version}</extra.source.dir>
36+
<extra.testsource.dir>src/test/scala-${scala.binary.version}</extra.testsource.dir>
3737
</properties>
3838

3939
<dependencies>
@@ -167,14 +167,4 @@
167167
</plugins>
168168
</build>
169169

170-
<profiles>
171-
<profile>
172-
<id>scala-2.12</id>
173-
<properties>
174-
<extra.source.dir>scala-2.12/src/main/scala</extra.source.dir>
175-
<extra.testsource.dir>scala-2.12/src/test/scala</extra.testsource.dir>
176-
</properties>
177-
</profile>
178-
</profiles>
179-
180170
</project>

0 commit comments

Comments
 (0)