How can I retrieve snapshot dependencies from Nexus using SBT?

时光毁灭记忆、已成空白 提交于 2019-11-27 17:11:52

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/4342079/how-can-i-retrieve-snapshot-dependencies-from-nexus-using-sbt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!