Include Dependencies in JAR Using SBT

Apparently, project dependencies are not packaged in a jar generated using:

sbt package 

How to enable dependencies?

+5
source share
2 answers

There is a project called onejar that will pack the project and all its dependencies into a single jar file. There is also an SBT plugin:

https://github.com/sbt/sbt-onejar

However, if you just want to create a standard package (deb, rpm, etc.), there is sbt-native-packager:

https://github.com/sbt/sbt-native-packager

It can put all your dependencies in a Linux package and add appropriate shells to load all your dependencies and run your program or service.

+3
source

Well, I use the sbt-assembly plugin to create jars with dependencies,

1) add sbt-assembly to projects/assembly.sbt

 echo 'addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.3")' > project/assembly.sbt 

2) run sbt clean assembly to create a jar that will create ${name}-assembly-${version}.jar in target/scala-${scalaVersion}

+6
source

Source: https://habr.com/ru/post/1232595/


All Articles