In sbt, how do you add a plugin that's in the local filesystem?

Something like this in project/project/Build.scala should do it:

import sbt._
object PluginDef extends Build {
    lazy val projects = Seq(root)
    lazy val root = Project("plugins", file(".")) dependsOn( shPlugin )
    lazy val shPlugin = uri("file:///tmp/sbt-sh")
}

Note that that the doubly-nested project directories are required. I'm not aware of any way to do this from an .sbt file (there may be a way, but I don't know what it is).

This is documented here (see "1d) Project dependency").


In 0.13, there's a) a simple way to do this, and b) better documentation. @PaulButcher's answer pointed to section 1d of the sbt documentation for plugins, which now tells you to edit project/plugins.sbt:

(@axel22 points out this has changed, so check the current doc before you copy this)

lazy val root = project.in( file(".") ).dependsOn( assemblyPlugin )
lazy val assemblyPlugin = uri("git://github.com/sbt/sbt-assembly#0.9.1")

And of course that uri(... can be replaced with a file("/tmp/sbt-sh").

Tags:

Scala

Sbt