Skip to content

mariussoutier/sbt-unpack

Repository files navigation

sbt-unpack

Simple plugin to unpack JARs in your project. Loosely based on ideas presented in Josh Suereth's book sbt in Action Chapter 7 and packaged into an auto plugin.

Installation

Add this to plugins.sbt:

addSbtPlugin("com.mariussoutier.sbt" % "sbt-unpack" % "0.9.5")

Usage

First, enable the plugin on the project you want to use it with.

lazy val root = project(...)
  .enablePlugins(com.mariussoutier.sbt.UnpackPlugin)

Then run unpackJars manually or execute it automatically by adding to a generator, for example:

import com.mariussoutier.sbt.UnpackKeys
// Unpacks whenever you compile
sourceGenerators in Compile += UnpackKeys.unpackJars
// Or if you want to execute another task after unpacking
sourceGenerators in Compile += Def.sequential(UnpackKeys.unpackJars, ...).taskValue

Configuration

Key Description
dependenciesJarDirectory Location of the unpacked dependency JARs
dependencyFilter Which dependencies to unpack
fileExcludeFilter Files inside the JARs that should be excluded while unpacking

Example:

import com.mariussoutier.sbt.UnpackKeys
import NameFilter._
.settings(
  UnpackKeys.dependencyFilter := { (fileName: String) => fileName.startsWith("example-") },
)