Skip to content

Commit

Permalink
Use resolution hooks (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
YannMoisan authored and alexarchambault committed Jul 24, 2019
1 parent df7e507 commit b33e914
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class AmmoniteSparkSessionBuilder
val sparkJars = sys.env.get("SPARK_HOME") match {
case None =>
println("Getting spark JARs")
SparkDependencies.sparkJars(interpApi.repositories(), Nil)
SparkDependencies.sparkJars(interpApi.repositories(), interpApi.resolutionHooks, Nil)
case Some(sparkHome) =>
// Loose attempt at using the scala JARs already loaded in Ammonite,
// rather than ones from the spark distribution.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ object SparkDependencies {

def sparkJars(
repositories: Seq[Repository],
resolutionHooks: mutable.Buffer[Fetch => Fetch],
profiles: Seq[String]
): Seq[URI] =
Fetch.create()
): Seq[URI] = {
val fetch = Fetch.create()
.addDependencies(sparkBaseDependencies(): _*)
.withRepositories(repositories: _*)
.withResolutionParams(
Expand All @@ -139,9 +140,12 @@ object SparkDependencies {
.forceVersion(Module.of("org.scala-lang", "scala-compiler"), scalaVersion)
.withProfiles(profiles.toSet.asJava)
)

resolutionHooks
.foldLeft(fetch){ case (acc, f) => f(acc) }
.fetch()
.asScala
.toVector
.map(_.getAbsoluteFile.toURI)

}
}

0 comments on commit b33e914

Please sign in to comment.