From a43159e6b58dba70e11b5f2f52abbc2ab4a577dc Mon Sep 17 00:00:00 2001 From: Prashant Sharma Date: Mon, 15 May 2017 12:23:58 +0530 Subject: [PATCH] [BUILD][MINOR] Hide building of docs in sbt behind an option. sbt publish-local tries to build the docs along with other artifacts and as the codebase is being updated with no build checks for sbt docs build. It appears to be difficult to upkeep the correct building of docs with sbt. An alternative is that, we hide building of docs behind an option `-Dbuild.docs=false`. This is also useful, if someone uses sbt publish and does not need the building of docs as it is generally time consuming. --- project/SparkBuild.scala | 41 ++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/project/SparkBuild.scala b/project/SparkBuild.scala index b5362ec1ae452..2d785cbee7b92 100644 --- a/project/SparkBuild.scala +++ b/project/SparkBuild.scala @@ -186,23 +186,32 @@ object SparkBuild extends PomBuild { Set(file) } - def enableScalaStyle: Seq[sbt.Def.Setting[_]] = Seq( - scalaStyleOnCompile := cachedScalaStyle(Compile).value, - scalaStyleOnTest := cachedScalaStyle(Test).value, - logLevel in scalaStyleOnCompile := Level.Warn, - logLevel in scalaStyleOnTest := Level.Warn, - (compile in Compile) := { - scalaStyleOnCompile.value - (compile in Compile).value - }, - (compile in Test) := { - scalaStyleOnTest.value - (compile in Test).value - } - ) + def enableScalaStyle: Seq[sbt.Def.Setting[_]] = if(sys.env.contains("NOLINT_ON_COMPILE")) { + Seq.empty + } else { + Seq( + scalaStyleOnCompile := cachedScalaStyle(Compile).value, + scalaStyleOnTest := cachedScalaStyle(Test).value, + logLevel in scalaStyleOnCompile := Level.Warn, + logLevel in scalaStyleOnTest := Level.Warn, + (compile in Compile) := { + scalaStyleOnCompile.value + (compile in Compile).value + }, + (compile in Test) := { + scalaStyleOnTest.value + (compile in Test).value + } + ) + } + + def enableBuildingDocs: Seq[sbt.Def.Setting[_]] = sys.props.get("build.docs") match { + case Some("false") => Seq(sources in (Compile,doc) := Seq.empty, + publishArtifact in (Compile, packageDoc) := false) + case _ => Seq.empty + } - lazy val sharedSettings = sparkGenjavadocSettings ++ - (if (sys.env.contains("NOLINT_ON_COMPILE")) Nil else enableScalaStyle) ++ Seq( + lazy val sharedSettings = sparkGenjavadocSettings ++ enableBuildingDocs ++ enableScalaStyle ++ Seq( exportJars in Compile := true, exportJars in Test := false, javaHome := sys.env.get("JAVA_HOME")