Tuesday, October 16, 2012

sbt: pushing and pulling from a local Nexus installation

Here's a simple build.sbt for pushing and pulling from a local Nexus repository.  The Nexus repository has almost no configuration changes; I've added a password for the deployment user (here given as "deploy"), but other than that it's running with the settings that came out of the box.  Note that the hostname in my case is "git", and Nexus uses the default port of 8081.

name := "fnord"

organization := "com.restphone"

version := "0.1-SNAPSHOT"

scalaVersion := "2.10.0-RC1"

// Compile for these Scala versions
crossScalaVersions := Seq("2.9.1", "2.9.2", "2.10.0-RC1")

publishMavenStyle := true

scalaSource in Compile <<= baseDirectory(_ / "src")

resolvers += "Sonatype OSS Snapshots" at "http://git:8081/nexus/content/repositories/snapshots"

resolvers += "Sonatype OSS Snapshots" at "http://git:8081/nexus/content/repositories/releases"

libraryDependencies ++= Seq(
  "com.restphone" % "artifactname" % "1.0"

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

credentials += Credentials("Sonatype Nexus Repository Manager",