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

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

问题描述

我有一个maven2存储库,我试图从中获取带有附加时间戳的快照工件.使用maven2构建时,但使用简单时,我能够(毫不奇怪)检索到它-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.

我可以从有关常春藤中快照的问题中看到,可以配置 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)

更新:经过更多的修改后,看来可以使用以下模式将其指向正确的工件网址.

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")

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

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天全站免登陆