6

I need to define as a dependency the following library:

url: http://deploy.cloud.testmx.com:8081/nexus/content/groups/public/

user: testmx

pass: testmx@testmx

groupId: testmx

artifactId: testmxcommons

version: 1.0.0-SNAPSHOT

So I defined the following project/Build.scala

import sbt._
import Keys._
import PlayProject._

object ApplicationBuild extends Build {

    val appName         = "testmxproject"
    val appVersion      = "1.0-SNAPSHOT"

    val appDependencies = Seq(
      "mysql" % "mysql-connector-java" % "5.1.18",
      "testmx" % "testmxcommons" % "1.0.0-SNAPSHOT"
    )

    val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
      credentials += ("testmx public", "deploy.cloud.testmx.com:8081", "testmx", "testmx@testmx"),
      resolvers += "testmx public" at "http://deploy.cloud.testmx.com:8081/nexus/content/groups/public/"
    )

}

and I get the following error:

[warn]  module not found: testmx#testmxcommons;1.0.0-SNAPSHOT

[warn] ==== testmx public: tried
[warn]   http://deploy.cloud.testmx.com:8081/nexus/content/groups/public/testmx/textmxcommons/1.0.0-SNAPSHOT/textmxcommons-1.0.0-SNAPSHOT.pom

I tried several alternatives but they give me the same error...

I've checked this article and this SO question

And also tried saving the user and password on an external file, as it's explained here and here.

any idea?

-- edit to clarify --

I changed the real url because it's not a public repo I'm working with... The real url is there and the pom that sbt is trying to find does exist...

ps: BTW.. where are sbt scaladocs???

Community
  • 1
  • 1
opensas
  • 60,462
  • 79
  • 252
  • 386

2 Answers2

11

You need to tell SBT what repository you want to publish to:

publishTo := Some("testmx public" at "http://deploy.cloud.testmx.com:8081/nexus")

Additionally if you don't want to keep your credentials in the Build file, you can tell it to retrieve them locally by adding the line:

credentials += Credentials(Path.userHome / ".ivy2" / ".credentials"),

And in your ~/.ivy2 directory create a .credentials file like this:

realm=Sonatype Nexus Repository Manager
host=deploy.cloud.testmx.com
user=testmx
password=testmx@testmx

See https://github.com/harrah/xsbt/wiki/Publishing for more

Chris Thompson
  • 35,167
  • 12
  • 80
  • 109
Manuel Bernhardt
  • 3,135
  • 2
  • 29
  • 36
  • thanks a lot for your answer manuel, I tried what you said but I'm still getting the same error, any way to debug sbt so as to know what credentials are being passed? – opensas Jun 06 '12 at 03:43
  • 2
    I had a similar problem today, and found Wireshark to be an effective way to see what was going wrong at the network level. In my case, I wasn't setting the Realm attribute to "Sonatype Nexus Repository Manager", so no password was being sent. – Alex Varju Jun 06 '12 at 04:48
  • You were right Alex, I was passing the wrong realm, which should be "Sonatype Nexus Repository Manager", but I still get the same error... gonna try with wireshark... – opensas Jun 06 '12 at 05:40
  • 1
    seems like the publishTo is not neccesary when you are only fetching dependencies... – opensas Jun 06 '12 at 06:27
6

There were two problems when passing the credentials.

The first was that I was passing the wrong Realm. (Thanks to Alex Varju for this one)

You have to pass the same Realm that the server is sending you when trying to log (Just press ctrl-shift-I or F12 on chromium and got to network to have a look at it)

The second problem is that I was passing the port number, and sbt doesn't seem to like that...

So, in the end I did it like this and it works ok:

val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
  credentials += ("Sonatype Nexus Repository Manager", "deploy.cloud.testmx.com", "testmx", "testmx@testmx"),
  resolvers += "testmx public" at "http://deploy.cloud.testmx.com:8081/nexus/content/groups/public/"
)

Settings your credentials in a different file, as expected, worked ok too with the same modifications...

Thanks to all for your answers

opensas
  • 60,462
  • 79
  • 252
  • 386