如何使用 SBT 从 Nexus 检索快照依赖项? [英] How can I retrieve snapshot dependencies from Nexus using SBT?

查看:46
本文介绍了如何使用 SBT 从 Nexus 检索快照依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 maven2 存储库,我试图从中获取带有附加时间戳的快照工件.我(不出所料)能够在使用 maven2 构建时很好地检索它,但是在使用 simple 构建时-build-tool (sbt),我很喜欢,我拉不下来.

I have a maven2 repository from which I'm trying to fetch an snapshot artifact with an appended timestamp. I'm (unsurprisingly) able to retrieve it fine when building with maven2 but when building with simple-build-tool (sbt), much preferred by me, I can't pull it down.

我可以从 this question about snapshots in Ivy 中看到可以配置 Ivy 来获取快照工件,但我不知道如何告诉 sbt去做吧.

I can see from this question about snapshots in Ivy that it is possible to configure Ivy to get snapshot artifacts but I don't know how to tell sbt to do it.

我当前配置的相关位:

val snapshotsName = "Snapshots Repository"
val snapshotsUrl = new java.net.URL("http://host:port/path/to/root")
val snapshotsPattern = "[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"
val snapshots = Resolver.url(snapshotsName, snapshotsUrl)(Patterns(snapshotsPattern))
Credentials(Path.userHome / ".ivy2" / ".credentials", log)

更新:经过更多修改后,看起来我可以使用以下模式让它指向正确的工件 url.

Update: After some more tinkering it looks like I can get it to point at the correct artifact url with the following pattern.

val snapshotsPattern = "[organisation]/[module]/[revision]-SNAPSHOT/[artifact]-[revision](-[timestamp]).[ext]"

我仍然需要在依赖项中额外指定时间戳

With that I still need to specify the timestamp extra in the dependency

val dep = "group" % "artifact" % "0.0.1" extra("timestamp" -> "20101202.195418-3")

但它确实拉动了工件.但是,它确实拉取工件的依赖项.所以看来我还是有问题.

but it does pull the artifact. However it does NOT pull the artifact's dependencies. So it seems I've still got something wrong.

推荐答案

好的,我解决了这个问题,但它实际上不是 SBT 问题,它是 100% 用户错误.

Alright, I got this sorted out but it wasn't actually an SBT problem it was 100% user error.

我使用的 Nexus 需要身份验证.我没有正确设置身份验证凭据(查看我的身份验证问题)并且因为它没有正确验证它没有找到元数据pom文件,所以SBT打印出它失败的错误消息我错误地认为它验证但不解决.所以我开始弄乱实际问题中所证明的模式.

The Nexus I was using required authentication. I didn't have the authentication credentials set up correctly (see my authentication question) and because it wasn't properly authenticating it wasn't finding the metadata pom files and so SBT printed out the error message that it was failing I, incorrectly, assumed it was authenticating but not resolving. So I started messing with the patterns as evidenced in the actual question.

但是,既然我已经正确设置了身份验证,我就改回了一个常规的存储库声明,如下所示:

However, now that I have authentication setup correctly I changed back to just a regular repository declaration like so:

val snapshotsRepo = "Snapshots Repository" at "http://host:port/path/to/snapshots/root/"

一切正常.检索工件并解决依赖关系.

and everything works. Artifacts are retrieved and dependencies resolved.

这篇关于如何使用 SBT 从 Nexus 检索快照依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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