Skip to content

Commit 2e0af87

Browse files
sarutakpwendell
authored andcommitted
[SPARK-3787][BUILD] Assembly jar name is wrong when we build with sbt omitting -Dhadoop.version
This PR is another solution for When we build with sbt with profile for hadoop and without property for hadoop version like: sbt/sbt -Phadoop-2.2 assembly jar name is always used default version (1.0.4). When we build with maven with same condition for sbt, default version for each profile is used. For instance, if we build like: mvn -Phadoop-2.2 package jar name is used hadoop2.2.0 as a default version of hadoop-2.2. Author: Kousuke Saruta <[email protected]> Closes #3046 from sarutak/fix-assembly-jarname-2 and squashes the following commits: 41ef90e [Kousuke Saruta] Merge branch 'master' of git://git.apache.org/spark into fix-assembly-jarname-2 50c8676 [Kousuke Saruta] Merge branch 'fix-assembly-jarname-2' of github.com:sarutak/spark into fix-assembly-jarname-2 52a1cd2 [Kousuke Saruta] Fixed comflicts dd30768 [Kousuke Saruta] Merge branch 'master' of git://git.apache.org/spark into fix-assembly-jarname2 f1c90bb [Kousuke Saruta] Fixed SparkBuild.scala in order to read `hadoop.version` property from pom.xml af6b100 [Kousuke Saruta] Merge branch 'master' of git://git.apache.org/spark into fix-assembly-jarname c81806b [Kousuke Saruta] Merge branch 'master' of git://git.apache.org/spark into fix-assembly-jarname ad1f96e [Kousuke Saruta] Merge branch 'master' of git://git.apache.org/spark into fix-assembly-jarname b2318eb [Kousuke Saruta] Merge branch 'master' of git://git.apache.org/spark into fix-assembly-jarname 5fc1259 [Kousuke Saruta] Fixed typo. eebbb7d [Kousuke Saruta] Fixed wrong jar name
1 parent 391080b commit 2e0af87

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

project/SparkBuild.scala

Lines changed: 13 additions & 3 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 {
@@ -118,6 +120,15 @@ object SparkBuild extends PomBuild {
118120

119121
override val userPropertiesMap = System.getProperties.toMap
120122

123+
val pom = loadEffectivePom(new File("pom.xml"),
124+
profiles = profiles,
125+
userProps = userPropertiesMap)
126+
127+
if (System.getProperty("hadoop.version") == null) {
128+
System.setProperty("hadoop.version",
129+
pom.getProperties.get("hadoop.version").asInstanceOf[String])
130+
}
131+
121132
lazy val MavenCompile = config("m2r") extend(Compile)
122133
lazy val publishLocalBoth = TaskKey[Unit]("publish-local", "publish local for m2 and ivy")
123134

@@ -303,8 +314,7 @@ object Assembly {
303314
// This must match the same name used in maven (see network/yarn/pom.xml)
304315
"spark-" + v + "-yarn-shuffle.jar"
305316
} else {
306-
mName + "-" + v + "-hadoop" +
307-
Option(System.getProperty("hadoop.version")).getOrElse("1.0.4") + ".jar"
317+
mName + "-" + v + "-hadoop" + System.getProperty("hadoop.version") + ".jar"
308318
}
309319
},
310320
mergeStrategy in assembly := {

0 commit comments

Comments
 (0)