Question

My company has several Maven-based projects which we publish to our locally hosted, private Nexus repository.

We also have a Play 2.1 based application which needs to use several of these artefacts.

How can I configure SBT so that it queries our local Nexus repository? Proxying all other Ivy and Maven Central dependencies through Nexus is not required, but considered a plus.

Was it helpful?

Solution

The following Build.scala retrieves private artefacts from the Nexus repository, retrieves other manually enrolled artefacts from the Nexus repository, and proxies Maven Central via Nexus:

import sbt._
import Keys._
import play.Project._

object ApplicationBuild extends Build 
{
  val appName         = "foo"
  val appVersion      = "0.0.1-SNAPSHOT"

  val appDependencies = Seq(
    javaCore,
    "com.private" % "foo" % "1.0.0"
  )

  val main = play.Project(appName, appVersion, appDependencies).settings(
    externalResolvers <<= resolvers map { rs => Resolver.withDefaultResolvers(rs, mavenCentral = false)},
    resolvers += "Nexus Public Proxy" at "http://private.com/nexus/content/groups/public/",
    resolvers += "Nexus 3rd party" at "http://private.com/nexus/content/repositories/thirdparty/",
    resolvers += "Nexus Private Releases" at "http://private.com/nexus/content/repositories/releases/"
  )
}

The Typesafe Ivy dependencies are still downloaded directly, as I couldn't get Nexus to proxy them successfully.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top