diff --git a/project/SparkBuild.scala b/project/SparkBuild.scala index de3871833b..b1d66686c9 100644 --- a/project/SparkBuild.scala +++ b/project/SparkBuild.scala @@ -802,11 +802,30 @@ object Hive { } object YARN { + val genConfigProperties = TaskKey[Unit]("gen-config-properties", + "Generate config.properties which contains a setting whether Hadoop is provided or not") + val propFileName = "config.properties" + val hadoopProvidedProp = "spark.yarn.isHadoopProvided" + lazy val settings = Seq( excludeDependencies --= Seq( ExclusionRule(organization = "com.sun.jersey"), ExclusionRule("javax.servlet", "javax.servlet-api"), - ExclusionRule("javax.ws.rs", "jsr311-api")) + ExclusionRule("javax.ws.rs", "jsr311-api")), + Compile / unmanagedResources := + (Compile / unmanagedResources).value.filter(!_.getName.endsWith(s"$propFileName")), + genConfigProperties := { + val file = (Compile / classDirectory).value / s"org/apache/spark/deploy/yarn/$propFileName" + val isHadoopProvided = SbtPomKeys.effectivePom.value.getProperties.get(hadoopProvidedProp) + IO.write(file, s"$hadoopProvidedProp = $isHadoopProvided") + }, + Compile / copyResources := (Def.taskDyn { + val c = (Compile / copyResources).value + Def.task { + (Compile / genConfigProperties).value + c + } + }).value ) }