If I want to add a plugin that's in a local directory outside the project tree, what's the right way to do that? Say I clone something simple like https://github.com/steppenwells/sbt-sh.git to /tmp/sbt-sh - what do I put in my build.sbt file to use the plugin from /tmp/sbt-sh that will pick up any changes I make in /tmp/sbt-sh?
Plugins can be installed for all your projects at once by dropping them in ~/. sbt/plugins/. ~/. sbt/plugins/ is an sbt project whose classpath is exported to all sbt build definition projects.
sbt/1.0/plugins/ is an sbt project whose classpath is exported to all sbt build definition projects. Roughly speaking, any . sbt or . scala files in $HOME/. sbt/1.0/plugins/ behave as if they were in the project/ directory for all projects.
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:
Up to 0.13.0:
(@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").
Update:
After sbt 0.13.0 you'll need to wrap the uri or file with RootProject
. I.e.,
lazy val root = project.in( file(".") ).dependsOn( assemblyPlugin )
lazy val assemblyPlugin = RootProject(file("lib/sbt-sh"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With