Tuesday, July 4, 2017

Create Scala Project using SBT and Jar using sbt-assembly


  1. Download and install SBT - http://www.scala-sbt.org/download.html
  2. Create SBT Scala Project by running this command - sbt new sbt/scala-seed.g8
  3. When prompted for the project name, type HelloWorld. This will create a new project under a directory named HelloWorld.
  4. Run the sample application by access HelloWorld folder, type sbt, compile and run.
  5. Add sbt-assembly as a dependency in project/assembly.sbt
    addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5")
  6. Type assembly.
  7. Now you'll have an awesome new assembly task which will compile your project, run your tests, and then pack your class files and all your dependencies into a single JAR file: target/scala_X.X.X/projectname-assembly-X.X.X.jar.
  8. Type java -jar target/scala_X.X.X/projectname-assembly-X.X.X.jar to run the program.
References:

No comments:

Post a Comment