1515 * limitations under the License.
1616 */
1717
18+ import java .io .File
19+
1820import scala .util .Properties
1921import scala .collection .JavaConversions ._
2022
@@ -23,7 +25,7 @@ import sbt.Classpaths.publishTask
2325import sbt .Keys ._
2426import sbtunidoc .Plugin .genjavadocSettings
2527import sbtunidoc .Plugin .UnidocKeys .unidocGenjavadocVersion
26- import com .typesafe .sbt .pom .{PomBuild , SbtPomKeys }
28+ import com .typesafe .sbt .pom .{loadEffectivePom , PomBuild , SbtPomKeys }
2729import net .virtualvoid .sbt .graph .Plugin .graphSettings
2830
2931object 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