aboutsummaryrefslogtreecommitdiff
path: root/project
diff options
context:
space:
mode:
authorReynold Xin <rxin@databricks.com>2015-07-22 21:02:19 -0700
committerReynold Xin <rxin@databricks.com>2015-07-22 21:02:19 -0700
commitd71a13f475df2d05a7db9e25738d1353cbc8cfc7 (patch)
tree1727247ac19f259b88c20633ef569d37277f4486 /project
parenta721ee52705100dbd7852f80f92cde4375517e48 (diff)
downloadspark-d71a13f475df2d05a7db9e25738d1353cbc8cfc7.tar.gz
spark-d71a13f475df2d05a7db9e25738d1353cbc8cfc7.tar.bz2
spark-d71a13f475df2d05a7db9e25738d1353cbc8cfc7.zip
[SPARK-9262][build] Treat Scala compiler warnings as errors
I've seen a few cases in the past few weeks that the compiler is throwing warnings that are caused by legitimate bugs. This patch upgrades warnings to errors, except deprecation warnings. Note that ideally we should be able to mark deprecation warnings as errors as well. However, due to the lack of ability to suppress individual warning messages in the Scala compiler, we cannot do that (since we do need to access deprecated APIs in Hadoop). Most of the work are done by ericl. Author: Reynold Xin <rxin@databricks.com> Author: Eric Liang <ekl@databricks.com> Closes #7598 from rxin/warnings and squashes the following commits: beb311b [Reynold Xin] Fixed tests. 542c031 [Reynold Xin] Fixed one more warning. 87c354a [Reynold Xin] Fixed all non-deprecation warnings. 78660ac [Eric Liang] first effort to fix warnings
Diffstat (limited to 'project')
-rw-r--r--project/SparkBuild.scala33
1 files changed, 32 insertions, 1 deletions
diff --git a/project/SparkBuild.scala b/project/SparkBuild.scala
index 12828547d7..61a05d375d 100644
--- a/project/SparkBuild.scala
+++ b/project/SparkBuild.scala
@@ -154,7 +154,38 @@ object SparkBuild extends PomBuild {
if (major.toInt >= 1 && minor.toInt >= 8) Seq("-Xdoclint:all", "-Xdoclint:-missing") else Seq.empty
},
- javacOptions in Compile ++= Seq("-encoding", "UTF-8")
+ javacOptions in Compile ++= Seq("-encoding", "UTF-8"),
+
+ // Implements -Xfatal-warnings, ignoring deprecation warnings.
+ // Code snippet taken from https://issues.scala-lang.org/browse/SI-8410.
+ compile in Compile := {
+ val analysis = (compile in Compile).value
+ val s = streams.value
+
+ def logProblem(l: (=> String) => Unit, f: File, p: xsbti.Problem) = {
+ l(f.toString + ":" + p.position.line.fold("")(_ + ":") + " " + p.message)
+ l(p.position.lineContent)
+ l("")
+ }
+
+ var failed = 0
+ analysis.infos.allInfos.foreach { case (k, i) =>
+ i.reportedProblems foreach { p =>
+ val deprecation = p.message.contains("is deprecated")
+
+ if (!deprecation) {
+ failed = failed + 1
+ }
+
+ logProblem(if (deprecation) s.log.warn else s.log.error, k, p)
+ }
+ }
+
+ if (failed > 0) {
+ sys.error(s"$failed fatal warnings")
+ }
+ analysis
+ }
)
def enable(settings: Seq[Setting[_]])(projectRef: ProjectRef) = {