Repository Management with Nexus

4.9. SBT

sbt has a built in dependency management component and defaults to the Maven repository format. In order to configure a sbt project to resolve dependencies declared in build.sbt file, a resolver as shown in ??? has to be declared

resolvers += "Nexus" at "http://localhost:8081/nexus/content/groups/public"

These minimal settings allow sbt to download the declared dependencies.

To deploy build outputs to a Nexus repository with the publish task, user credentials can be declared in the build.sbt file:

credentials += Credentials("Sonatype Nexus Repository Manager",
"nexus.scala-tools.org", "admin", "admin123")

and then used in the publishTo configuration:

publishTo <<= version { v: String =>
  val nexus = "http://localhost:8081/nexus/"
  if (v.trim.endsWith("SNAPSHOT"))
    Some("snapshots" at nexus + "content/repositories/snapshots")
  else
    Some("releases" at nexus + "content/repositories/releases")

Further documentation can be found in the sbt documentation on publishing.