Skip to content

Commit f1c90bb

Browse files
committed
Fixed SparkBuild.scala in order to read hadoop.version property from pom.xml
1 parent af6b100 commit f1c90bb

File tree

2 files changed

+12
-27
lines changed

2 files changed

+12
-27
lines changed

pom.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,8 +1174,6 @@
11741174

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

1177-
<!-- NOTE: If you change the default versions for each profile,
1178-
also corresponding section in project/SparkBuild.scala should be changed. -->
11791177
<profile>
11801178
<id>hadoop-0.23</id>
11811179
<!-- SPARK-1121: Adds an explicit dependency on Avro to work around a Hadoop 0.23.X issue -->

project/SparkBuild.scala

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import java.io.File
19+
1820
import scala.util.Properties
1921
import scala.collection.JavaConversions._
2022

@@ -23,7 +25,7 @@ import sbt.Classpaths.publishTask
2325
import sbt.Keys._
2426
import sbtunidoc.Plugin.genjavadocSettings
2527
import sbtunidoc.Plugin.UnidocKeys.unidocGenjavadocVersion
26-
import com.typesafe.sbt.pom.{PomBuild, SbtPomKeys}
28+
import com.typesafe.sbt.pom.{loadEffectivePom, PomBuild, SbtPomKeys}
2729
import net.virtualvoid.sbt.graph.Plugin.graphSettings
2830

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

102-
// NOTE: If you change the default version for each profile,
103-
// also corresponding section in pom.xml should be changed.
104-
if (System.getProperty("hadoop.version") == null) {
105-
val hadoopVersion = {
106-
if (profiles.contains("hadoop-0.23")) {
107-
"0.23.10"
108-
} else if (profiles.contains("hadoop-2.2")) {
109-
"2.2.0"
110-
} else if (profiles.contains("hadoop-2.3")) {
111-
"2.3.0"
112-
} else if (profiles.contains("hadoop-2.4")) {
113-
"2.4.0"
114-
} else if (profiles.contains("mapr3")) {
115-
"1.0.3-mapr-3.0.3"
116-
} else if (profiles.contains("mapr4")) {
117-
"2.3.0-mapr-4.0.0-FCS"
118-
} else {
119-
// Default
120-
"1.0.4"
121-
}
122-
}
123-
System.setProperty("hadoop.version", hadoopVersion)
124-
}
125-
126104
Properties.envOrNone("SBT_MAVEN_PROPERTIES") match {
127105
case Some(v) =>
128106
v.split("(\\s+|,)").filterNot(_.isEmpty).map(_.split("=")).foreach(x => System.setProperty(x(0), x(1)))
@@ -131,6 +109,15 @@ object SparkBuild extends PomBuild {
131109

132110
override val userPropertiesMap = System.getProperties.toMap
133111

112+
val pom = loadEffectivePom(new File("pom.xml"),
113+
profiles = profiles,
114+
userProps = userPropertiesMap)
115+
116+
if (System.getProperty("hadoop.version") == null) {
117+
System.setProperty("hadoop.version",
118+
pom.getProperties.get("hadoop.version").asInstanceOf[String])
119+
}
120+
134121
lazy val MavenCompile = config("m2r") extend(Compile)
135122
lazy val publishLocalBoth = TaskKey[Unit]("publish-local", "publish local for m2 and ivy")
136123

0 commit comments

Comments
 (0)