Skip to content

Commit

Permalink
Fixed SparkBuild.scala in order to read hadoop.version property fro…
Browse files Browse the repository at this point in the history
…m pom.xml
  • Loading branch information
sarutak committed Nov 1, 2014
1 parent af6b100 commit f1c90bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 27 deletions.
2 changes: 0 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1174,8 +1174,6 @@

<!-- A series of build profiles where customizations for particular Hadoop releases can be made -->

<!-- NOTE: If you change the default versions for each profile,
also corresponding section in project/SparkBuild.scala should be changed. -->
<profile>
<id>hadoop-0.23</id>
<!-- SPARK-1121: Adds an explicit dependency on Avro to work around a Hadoop 0.23.X issue -->
Expand Down
37 changes: 12 additions & 25 deletions project/SparkBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* limitations under the License.
*/

import java.io.File

import scala.util.Properties
import scala.collection.JavaConversions._

Expand All @@ -23,7 +25,7 @@ import sbt.Classpaths.publishTask
import sbt.Keys._
import sbtunidoc.Plugin.genjavadocSettings
import sbtunidoc.Plugin.UnidocKeys.unidocGenjavadocVersion
import com.typesafe.sbt.pom.{PomBuild, SbtPomKeys}
import com.typesafe.sbt.pom.{loadEffectivePom, PomBuild, SbtPomKeys}
import net.virtualvoid.sbt.graph.Plugin.graphSettings

object BuildCommons {
Expand Down Expand Up @@ -99,30 +101,6 @@ object SparkBuild extends PomBuild {
v.split("(\\s+|,)").filterNot(_.isEmpty).map(_.trim.replaceAll("-P", "")).toSeq
}

// NOTE: If you change the default version for each profile,
// also corresponding section in pom.xml should be changed.
if (System.getProperty("hadoop.version") == null) {
val hadoopVersion = {
if (profiles.contains("hadoop-0.23")) {
"0.23.10"
} else if (profiles.contains("hadoop-2.2")) {
"2.2.0"
} else if (profiles.contains("hadoop-2.3")) {
"2.3.0"
} else if (profiles.contains("hadoop-2.4")) {
"2.4.0"
} else if (profiles.contains("mapr3")) {
"1.0.3-mapr-3.0.3"
} else if (profiles.contains("mapr4")) {
"2.3.0-mapr-4.0.0-FCS"
} else {
// Default
"1.0.4"
}
}
System.setProperty("hadoop.version", hadoopVersion)
}

Properties.envOrNone("SBT_MAVEN_PROPERTIES") match {
case Some(v) =>
v.split("(\\s+|,)").filterNot(_.isEmpty).map(_.split("=")).foreach(x => System.setProperty(x(0), x(1)))
Expand All @@ -131,6 +109,15 @@ object SparkBuild extends PomBuild {

override val userPropertiesMap = System.getProperties.toMap

val pom = loadEffectivePom(new File("pom.xml"),
profiles = profiles,
userProps = userPropertiesMap)

if (System.getProperty("hadoop.version") == null) {
System.setProperty("hadoop.version",
pom.getProperties.get("hadoop.version").asInstanceOf[String])
}

lazy val MavenCompile = config("m2r") extend(Compile)
lazy val publishLocalBoth = TaskKey[Unit]("publish-local", "publish local for m2 and ivy")

Expand Down

0 comments on commit f1c90bb

Please sign in to comment.