如何使用 SBT 从 Nexus 检索快照依赖项?

发布于 2024-10-05 14:03:14 字数 1263 浏览 5 评论 0原文

我有一个 maven2 存储库,我试图从中获取带有附加时间戳的快照工件。我(毫不奇怪)能够在使用 maven2 构建时很好地检索它,但在使用 simple 构建时能够很好地检索它-build-tool (sbt),我更喜欢,我无法将其拉下来。

我可以从这个关于ivy中的快照的问题中看到这是可能的配置 Ivy 来获取快照工件,但我不知道如何告诉 sbt 这样做。

我当前配置的相关部分:

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。

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

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

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

但它确实会拉动工件。然而,它提取工件的依赖项。所以看来我还是有问题。

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.

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.

The relevant bits of my current configuration:

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)

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮年 2024-10-12 14:03:14

好吧,我已经解决了这个问题,但这实际上不是 SBT 问题,而是 100% 用户错误。

Nexus I 使用必需的身份验证。我没有正确设置身份验证凭据(请参阅我的身份验证问题),并且因为它没有正确进行身份验证,所以没有找到元数据 pom 文件,因此 SBT 打印出失败的错误消息,我错误地认为它是正在验证但未解决。所以我开始搞乱实际问题中所证明的模式。

但是,现在我已经正确设置了身份验证,我改回了常规存储库声明,如下所示:

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

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

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文