使用 SBT 和 SNAPSHOT 依赖项脱机工作 [英] Working offline with SBT and SNAPSHOT dependencies

查看:35
本文介绍了使用 SBT 和 SNAPSHOT 依赖项脱机工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从来没有能够在我的任何项目中使用 SBT 离线工作.现在我正在搬家,我的衣橱服务器托管连接已离线.

I have never been able to work offline with SBT on any of my projects. Now I'm in the middle of a move and my wardrobe-server hosting nexus is offline.

所以说:

sbt "set offline := true" run

我得到了其他缺失的部门:

I get among other missing deps:

[error] unresolved dependency: se.hedefalk#lift-utils_3.0_2.10;0.2-SNAPSHOT: not found

对于声明为的依赖项:

"se.hedefalk"       %% ("lift-utils_"+liftEdition) % ("0.2-SNAPSHOT"),

但我的常春藤缓存中确实存在依赖项:

But I do have the dependency in my ivy cache:

$ ll ~/.ivy2/cache/se.hedefalk/lift-utils_3.0_2.10/
total 32
drwxr-xr-x  8 viktor  staff   272B Mar 14 11:36 ./
drwxr-xr-x  5 viktor  staff   170B Mar  8 10:38 ../
drwxr-xr-x  3 viktor  staff   102B Mar 14 11:36 docs/
-rw-r--r--  1 viktor  staff   4.5K Mar  4 15:54 ivy-0.2-SNAPSHOT.xml
-rw-r--r--  1 viktor  staff   4.0K Mar  4 15:54 ivy-0.2-SNAPSHOT.xml.original
-rw-r--r--  1 viktor  staff   1.8K Mar 14 11:36 ivydata-0.2-SNAPSHOT.properties
drwxr-xr-x  3 viktor  staff   102B Mar  8 10:38 jars/
drwxr-xr-x  3 viktor  staff   102B Mar 14 11:36 srcs/

这还不够吗?整套离线:= true"对我来说从来没有任何不同.依赖解决似乎以前发生过.

Shouldn't that be enough? That whole set "offline := true" has never ever made any difference for me. The dependency resolution seems to happen before.

我现在真的需要让它工作.多年来我一直遇到这个问题,但现在我处于根本无法工作的境地.

I really need to get this working now. I have had problems with this for years, but now I'm in the situation where I simply cannot work at all.

这里:http://www.scala-sbt.org/0.13.5/docs/Detailed-Topics/Dependency-Management-Flow.html

我读过

当离线 := true 时,远程 SNAPSHOT 不会被解决方案,甚至是明确要求的更新.这应该有效地支持在没有远程连接的情况下工作存储库.以其他方式证明的可重复示例是赞赏.显然,更新之前必须已经成功运行离线.<​​/p>

When offline := true, remote SNAPSHOTs will not be updated by a resolution, even an explicitly requested update. This should effectively support working without a connection to remote repositories. Reproducible examples demonstrating otherwise are appreciated. Obviously, update must have successfully run before going offline.

我可能没有正确理解这一点,但这是说我不应该遇到我遇到的问题吗?

I probably don't understand this correctly, but is it saying I shouldn't have the problem I have?

我有同样的问题使用:

> sbt "skip in update := true" run

使用 sbt 0.13.5

Using sbt 0.13.5

在我的 repo 再次联机后,解决所有 deps,然后将我的 wifi 设置为脱机,我可以退出 sbt 然后运行它.但是,只需运行 ;reload ;clean ;compile ,我就又被搞砸了.如果我退出,我什至根本无法启动 sbt.项目的依赖关系解析发生在我可以尝试使用依赖树或类似文件分析依赖图之前.即使不是在线的,如果说试图了解失败的传递依赖来自何处,这也是非常令人恼火的.

After having my repo online again, resolving all deps and then just setting my wifi to offline I can exit sbt and then run it. However, just running ;reload ;clean ;compile and I'm f***ed again. And If I exit I'm not even able to start sbt at all. Dependency resolution for the project happens before I can for instance try to analyse the dependency graph with dependency-tree or similar. This is highly irritating even if not online if say, trying to understand where a failing transitive dependency comes from.

推荐答案

这似乎是一个可怕的 hack,但是你可以将你的 ivy 缓存指定为一个 ivy 存储库,这样一旦你的依赖被下载,它们就可以从缓存.

This seems like a terrible hack, but you can specify your ivy cache as an ivy repository, so that once your dependencies are downloaded, they can be resolved from the cache.

例如,您的 ~/.sbt/repositories 可能如下所示:

For example, your ~/.sbt/repositories could look like this:

[repositories]
  local
  maven-central
  cache: file://${user.home}/.ivy2/cache, [organisation]/[module]/ivy-[revision].xml, [organisation]/[module]/[type]s/[module]-[revision].[type]

注意:我必须明确设置 ivy 和 artifact 模式.在任何其他 repos 下方添加本地缓存,以便首先尝试它们.

Note: I had to set the ivy and artifact patterns explicitly. Add the local cache below any other repos so they get tried first.

这篇关于使用 SBT 和 SNAPSHOT 依赖项脱机工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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