Add a Github Project as a Dependency in SBT

Add a Github Project as a Dependency in SBT

Last updated:
Add a Github Project as a Dependency in SBT
Table of Contents

TL;DR Clone project, use sbt-assembly to generate the JAR and add it as an unmanaged dependency. See working code here (project your want to import) and here(your project)

You probably know by know that Java and Scala aren't like interpreted languages where the dependencies are source code.

Dependencies for Java and Scala are JAR files so you can't just add a github project as a dependency to your code because the project needs to be compiled into a JAR for you to use it.

Git clone the project

The github project should be a valid SBT project

$ git clone

Add sbt-assembly to the project you've cloned

The project you want to depend on might have its own dependencies and so on and, since you may not have it in your own code, you need to include them in the packaged JAR as well. We'll use sbt-assembly for that.

It's likely the project doesn't itself include sbt-assembly so create a file under some-project-name/project/ called assembly.sbt and add the following content:

// some-project-name/project/assembly.sbt
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.3")

Package the whole thing into a single (fat) JAR

It's called a fat JAR file because it includes all of its dependencies along with it.

$ cd some-project-name
some-project-name$ sbt assembly

This command will generate a JAR file probably at this location::


(this will be different depending on whether you are using Scala 2.10 vis-a-vis 2.11 and if you have a different version string)

Move the generated JAR file to your own project

Now you need to copy the JAR file you generated in the previous step to your actual project.

To add the generated JAR file to your own project so that you can use it, place it under my-sbt-project/lib/, which is where SBT looks for unmanaged dependency JARs (i.e. those that aren't at maven central or somewhere like that.)

Instead of manually placing the generated JAR in your project, you can upload it to a repository like Bintray, for free: Publishing an SBT Project onto Bintray: an Example

$ ls my-sbt-project/lib

One you do this, you will be able to import packages and classes from some-project-name in your project, and use them.

More info