in scala sbt jar assembly ~ read.

How to build jar out of your scala project using assembly

Currenty, in my free time, i'm working on my own project that will allow in the future to generate beautiful and meaningful test data for automated tests. The idea is to have it as a jar file that will be either included into project manually, or via maven. That's why i decided to check how to create a jar out of scala project. After some trials and googling i came to next approach :

  1. You need to add to your project's plugins.sbt file next line :
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
  1. In your project root create assembly.sbt file
  2. Add to your assembly.sbt file next lines :
import AssemblyKeys._

assemblySettings

lazy val buildSettings = Seq(
  version := "0.1-SNAPSHOT",
  organization := "com.github",
  scalaVersion := "2.10.1"
)

jarName in assembly := "$jarFileName.jar"

To build your jar file you need to run sbt console and then execute next commands :

reload
compile
assembly

For more options and details regarding assembly you can find here

Have fun building cool jar's out of your scala projects :)

comments powered by Disqus
comments powered by Disqus