Skip to content
A sbt plugin for creating distributable Scala packages.
Scala Shell HTML
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

sbt-pack plugin

A sbt plugin for creating distributable package with dependent jars and launch scripts.


sbt-pack plugin do the following things:

  • With sbt pack command, it creates a distributable package in target/pack folder.
  • All dependent jars are collected in target/pack/lib folder. No need exists to create a single-jar as in sbt-assembly or proguard plugins.
    • Support multi-module projects.
  • You can run your programs using a script in target/pack/bin/{program name}
  • You can install your Scala programs to local machine cd target/pack; make install. Then you can run the command with ~/local/bin/{program name}
  • The above install Makefile script uses a separate folder for each program version (e.g., ~/local/{project name}/{project version}), so you can have several versions of your program in a system. The latest one is linked from ~/local/{project name}/current
  • You can add other resources to be packed in src/pack folder.


Add sbt-pack plugin:


addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.1")

Import xerial.sbt.Pack.packSettings into your project settings. Then set packMain variable, a mapping from the your program names to their corresponding main classes. The main classes must be Scala objects that define def main(args:Array[]) method:


import sbt._
import sbt.Keys._
import xerial.sbt.Pack._

object Build extends sbt.Build {

  lazy val root = Project(
    id = "example1",
    base = file("."),
    settings = Defaults.defaultSettings ++ packSettings ++
        // Map from program name -> Main class (full path)
        packMain := Map("hello" -> "myprog.Hello"),
        // custom settings here
        crossPaths := false,
        //libraryDependencies += ...


package myprog

object Hello {
  def main(args:Array[String]) = {
    println("Hello World!!")

Create a package

$ sbt pack

Your program package will be generated in target/pack folder.

Other examples of projects

See examples folder of this source code.

Something went wrong with that request. Please try again.