Adding Jars to a classpath should not be a chore. Often, using retrieveManaged in an SBT build is not quite what we want. When dealing with more than a few minor dependencies, having each dependency placed in its own folder is problematic. This article discusses a solution to this issue using Xerial’s sbt-pack plugin.
Xerial offers a plugin that will package all jars in a single folder and create a bat for executing the configurable main class. This allows for every jar to be placed on the classpath without listing every folder. It also creates a single directory for all dependencies.
Simply place the following in project/plugins.sbt:
addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.8.2") // for sbt-0.13.x or higher
Then specify the packaging options in build.sbt:
In this instance, the main class will be automatically found. More options are discussed at the Xerial Github page.
Packaging the jars requires a single command:
Using the classpath with many dependencies does not need to be a chore. Simply import the Xerial plugin and run sbt pack