Publishing an SBT Project onto Bintray: an Example

Publishing an SBT Project onto Bintray: an Example

Last updated:
Publishing an SBT Project onto Bintray: an Example
Table of Contents

As explained in the post Add a Github Project as a Dependency in SBT, it is not as easy to add dependencies to Scala/Java projects as it is for interpreted languages because we need to compile sources prior to using them.

Although you can just build the package your project and use it as an unmanaged dependency, placing the package on a publicly available platform like bintray allows more people to use it and keep track of newer versions as they come.

So here's a quick example of the steps you need to take to publish a package on bintray, and how to reference it.

TL; DR: Here's a project using the configs explained on this post: scala-date-time-utils

bintray-sbt plugin

We'll be using sbt/bintray-sbt, which is an sbt plugin made for this specific purpose.

Add the following to project/plugins.sbt:

A newer version (0.4.0) is available but there are, as of this writing, some show stopper bugs such as this one

addSbtPlugin("me.lessis" % "sbt-bintray" % "0.3.0")



Add the following to ~/.bintray/.credentials, replacing stuff with your own values.

realm = Bintray API Realm
host =
user = <insert-your-username-here>
password = <insert-your-key-here>


Add the following to build.sbt, replacing stuff with your own values.

name := "<your-project-name>"

scalaVersion := "2.11.8"

// change this if you need to
version := "0.1.0"

organization := "<your-organization-name>"

// not needed if you don't use scalatest
libraryDependencies += "org.scalatest" %% "scalatest" % "2.2.6" % "test"

// you can choose other licenses too
licenses += ("MIT", url(""))


You just need to run sbt publish to package your project and upload it to bintray.

If you've followed all the steps correctly, you should see something like this:

$ sbt publish
[info] Loading project definition from /home/felipe/scala-date-time-utils/project
[info] Set current project to scala-date-time-utils (in build file:/home/felipe/scala-date-time-utils/)
[info]  published scala-date-time-utils_2.11 to
[info] queirozfcom/scala-date-time-utils@0.1.0 was released


Using your project

You don't need to add the plugin to plugins.sbt if you just want to use a package on bintray

Add the following to build.sbt, replacing stuff with your own values, the same you've used in previous steps.

resolvers += Resolver.bintrayRepo("<your-bintray-username>","maven")

libraryDependencies += "<your-organization-name>" %% "<your-project-name>" % "0.1.0"

Done. You can start importing classes and methods from your package on bintray now

Cross-Building your project for Scala 2.11 and 2.10

You should probably publish your library for both Scala 2.11 and Scala 2.10, since we know these versions are not binary-compatible.

You can do that quite easily. Add crossScalaVersions key to your build.sbt file, as follows:

// add this to build.sbt to build your project against these scala versions
crossScalaVersions := Seq("2.11.8","2.10.6")

In addition to that, you need to change the command you use for actually publishing the project to bintray. So instead of using publish, use +publish:

$ sbt "+publish"

See also: SBT Docs: Cross building a project