Skip to main content

SBT (Nexus Repository 2)

Nexus Repository 2

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 SBT Resolvers Configuration has to be declared.

SBT Resolvers Configuration

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 repository with the publish task, user credentials can be declared in the build.sbt file:

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

Note

The credentials string should never change, as third-party clients depend on it

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.