SBT 可以刷新 git uri 依赖项(总是或按需)? [英] Can SBT refresh git uri dependency (always or on demand)?

查看:14
本文介绍了SBT 可以刷新 git uri 依赖项(总是或按需)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下 sbt 代码来添加对 git uri 的插件依赖:

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://$username@git-repo.org/team/build.git#build_0.1")
  )
}

这很好,但是我发现如果我对 build_0.1 进行更改并推送它,当我再次 compile 项目时,sbt 不会拉我所做的更改,所以我有一个过时的插件.

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.

如何让 SBT 始终对它所依赖的依赖项执行 git pull?

How can I get SBT to always do a git pull on the dependencies it depends on?

推荐答案

SBT 最高 0.13.2-M1 支持 git clonegit checkout 仅.

SBT up to 0.13.2-M1 supports git clone and git checkout only.

git clone 用于当 URL 不包含 # 以指向分支或提交时,例如

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 在 URL 中有 # 指向分支或提交时执行,例如

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

当我 commit 对 git 存储库进行更改时,我还必须更新 build.sbt 中的提交哈希,以便在SBT 项目(下面的 val v).

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

随着 git 存储库中的更改,必须对 SBT 项目进行重新加载,以便可以运行新的签出并刷新项目.

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]>

这很痛苦,但可以解决问题(并让您使用远程 git 存储库跟踪您的位置).

It's painful, but does the trick (and let you track where you are with the remote git repo).

您可能还会发现 GIT 中的多项目可以用作 SBT 依赖项吗? 很有用.

You may also find Can multi-projects from GIT be used as SBT dependencies? useful.

这篇关于SBT 可以刷新 git uri 依赖项(总是或按需)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆