I have the following sbt code to add a plugin dependency on a git uri:
import sbt._
object Plugins extends Build {
lazy val username = ("git config --global user.bitbucket" !!).trim
lazy val root = Project("root", file(".")) dependsOn(
uri(s"https://[email protected]/team/build.git#build_0.1")
)
}
This works fine, but I find that if I make changes to build_0.1
and push it, when I come to compile
the project again, sbt does not pull the changes I've made so I have an out of date plugin.
How can I get SBT to always do a git pull on the dependencies it depends on?
SBT up to 0.13.2-M1 supports git clone
and git checkout
only.
git clone
is used when the URL doesn't contain #
to point at a branch or a commit, e.g.
git:file:///Users/jacek/sandbox/so/sbt-git/git-repo
git checkout
is executed when the URL has #
in the URL that points at a branch or a commit, e.g.
git:file:///Users/jacek/sandbox/so/sbt-git/git-repo/#a221379c7f82e5cc089cbf9347d473ef58255bb2
When I commit
'ed a change to a git repo, I had to update the commit hash in build.sbt
, too, to have the change referenced in the SBT project (the val v
below).
lazy val v = "a221379c7f82e5cc089cbf9347d473ef58255bb2"
lazy val g = RootProject(uri(s"git:file:///Users/jacek/sandbox/so/sbt-git/git-repo/#$v"))
lazy val root = project in file(".") dependsOn g
With changes in the git repository, the SBT project has to be reload
'ed so a new checkout can be run and the project gets refreshed.
[root]> reload
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Loading project definition from /Users/jacek/sandbox/so/sbt-git/project
Cloning into '/Users/jacek/.sbt/0.13/staging/24535507588417c1c2dc/git-repo'...
Checking connectivity... done
[info] Set current project to root (in build file:/Users/jacek/sandbox/so/sbt-git/)
[root]>
It's painful, but does the trick (and let you track where you are with the remote git repo).
You may also find Can multi-projects from GIT be used as SBT dependencies? useful.
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