Use SBT and Git to create Your Own Maven Repository

By leverage SBT and Git, it is very easy to deploy your own distributed Maven Repository.

Publishing to Maven Repository

In your build.sbt, add:

publishTo := Some(Resolver.file("file",  new File(Path.userHome.absolutePath+"/mvn-repo")))

This publishTo defines the local directory for your Maven Repository. Alternatively you can also publish to http or ssh server. But that is out of the scope of this post.

To publish, run sbt command:

sbt publish

The published artifacts will be build for the scala version you use. You can specify the scala version in your build.sbt:

scalaVersion := "2.11.6"


To support multiple incompatible Scala versions, use command:

sbt +publish

You can also specify the Scala versions for cross publishing in your build.sbt:

crossScalaVersions := Seq("2.9.3", "2.10.6")

Push to servers

For me I push my personal Maven Repository to both Github and Bitbucket:

Use in Your Project

To use the Maven Repository in your project, you need to add the resolvers:

resolvers += "janzhou" at ""

Add artificial build for the scala version used:

libraryDependencies += "org.janzhou" %% "native" % "0.1.0"

Or specify the scala version:

libraryDependencies += "org.janzhou" % "native_2.11" % "0.1.0"

Notice the difference between %% and %