How can sbt pull dependency artifacts from git?

You can import unpackaged dependencies into your project from GitHub by treating them as project dependencies, using the dependsOn operator. (This is distinct from the way that precompiled library dependencies are included).

Note that you can specify which branch to pull using # notation. Here’s some Scala SBT code that is working well for me:

object V {
  val depProject = "master"
  // Other library versions
}

object Projects {
  lazy val depProject = RootProject(uri("git://github.com/me/dep-project.git#%s".format(V.depProject)))
}

// Library dependencies
lazy val myProject = Project("my-project", file("."))
.settings(myProjectSettings: _*)
.dependsOn(Projects.depProject)
.settings(
  libraryDependencies ++= Seq(...

Note that if you have multiple SBT projects dependending on the same external project, it’s worth setting up a central sbt.boot.directory to avoid unnecessary recompilations (see instructions here).

Leave a Comment