Question: I've heard (and I know I've seen examples too, if only I can remember where) that `sbt` can obtain dependencies from a git repo.

I am looking to obtain the dependency [harrah/up](https://github.com/harrah/up) from github. The repository does not provide any artifact JAR files, only a source tree which is set up to be built using `sbt`. The process that I am imagining is that `sbt` will download the source repo, build it, and then use that as the dependency artifact.

I may be imagining that `sbt` can in fact do something like this. Can it? And if so, how?

Answer: 
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](https://github.com/sbt/sbt/issues/35)).
Since I had problems getting the dependencies of my library resolved (using the suggested `RootProject`) I'd like to point out to the object called `ProjectRef`. Thus, if one need to depend on a library residing in git, I suggest to do so as follows:

```
import sbt.Keys._
import sbt._

object MyBuild extends Build {

  lazy val root = Project("root", file("."))
    .dependsOn(myLibraryinGit)
    .settings(
      ...,
      libraryDependencies ++= Seq(...))

  lazy val myLibraryinGit = ProjectRef(uri("git://git@github.com:user/repo.git#branch"), "repo-name")

}

```

*Source: <http://blog.xebia.com/git-subproject-compile-time-dependencies-in-sbt/>*