SBT能否刷新git uri的依赖(总是或按需)?

编程入门 行业动态 更新时间:2024-10-27 09:34:00
本文介绍了SBT能否刷新git uri的依赖(总是或按需)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下sbt代码在git uri上添加插件依赖项:

import sbt._ 对象插件扩展Build { lazy val username =(git config --global user.bitbucket!!)。trim b $ b lazy val root = Project(root ,file(。))dependsOn( uri(shttps://$username@git-repo/team/build.git#build_0.1))

这很好,但我发现如果我对 build_0.1 并推送它,当我再次来到编译项目时,sbt并没有拉取我所做的更改,所以我有一个过时的插件。

如何让SBT总是对它所依赖的依赖进行git pull?

0.13.2-M1 支持 git clone 和 c> git checkout 。

git clone t包含#指向a分支或提交,例如

git:file:/// Users / jacek / sandbox / so / sbt-git / git -repo

git checkout URL指向分支或提交的URL #,例如

git:file:/// Users / jacek / sandbox / so / sbt-git / git-repo /#a221379c7f82e5cc089cbf9347d473ef58255bb2

当我 commit '改变了一个git仓库时,我必须更新 build.sbt ,以便在SBT项目中引用更改(下面的val v )。

lazy val v =a221379c7f82e5cc089cbf9347d473ef58255bb2 lazy val g = RootProject(uri(sgit:file:/// Users / jacek / sandbox /所以/ sbt-git / git-repo /#$ v)) lazy val root =文件中的项目(。)dependsOn g

随着git版本库的变化,SBT项目必须被 reload 'ed所以一个新的结账可以运行并且项目被刷新。

[root]>重载 [info]从/Users/jacek/.sbt/0.13/plugins加载全局插件 [info]从/ Users / jacek / sandbox / so / sbt-git / project加载项目定义克隆到'/Users/jacek/.sbt/0.13/staging/24535507588417c1c2dc/git-repo'... 检查连通性...完成 [info]将当前项目设置为root(in build file:/ Users / jacek / sandbox / so / sbt-git /) [root]>

这很痛苦,但是诀窍(让你跟踪远程git仓库的位置) 。

您也可以找到 GIT的多项目可以用作SBT依赖关系?有用。

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"$username@git-repo/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.

更多推荐

SBT能否刷新git uri的依赖(总是或按需)?

本文发布于:2023-11-25 03:50:10,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按需   SBT   git   uri

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!