Scoped sbt-assembly

May 30, 2012

sbt-assembly is a handy sbt plugin which approximates the behavior of the Maven Assembly Plugin. By default, sbt-assembly extracts and bundles every project dependency into the final package, however it can be useful to limit dependencies to those in a certain scope. This is easily achieved by overriding the assemblyPath method:

class MyProject(info: ProjectInfo) extends DefaultProject(info) with assembly.AssemblyBuilder {
  override def assemblyClasspath = fullClasspath(config("compile"))
  // etc.

This will include only dependencies in the compile scope and exclude those of other scopes (provided, test, and so on).