4
votes

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
I tried to use an ivysettings.xml file to define the resolver but it doesn't appear to be getting read by SBT. I also tried to inline the resolver XML.Bryan J Swift

1 Answers

2
votes

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.