Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add unmanaged JARs in sbt-assembly to the final fat JAR?

My project has dependencies on a JAR file that isn't in Ivy, how can I include it directly in the final JAR output by sbt-assembly?

like image 203
Garrett Hall Avatar asked Sep 11 '13 19:09

Garrett Hall


People also ask

What is assembly JAR SBT?

The sbt-assembly plugin is an SBT plugin for building a single independent fat JAR file with all dependencies included. This is inspired by the popular Maven assembly plugin, which is used to build fat JARs in Maven.

How do I run a JAR file in SBT?

Solution. Create a directory layout to match what SBT expects, then run sbt compile to compile your project, sbt run to run your project, and sbt package to package your project as a JAR file. Unlike Java, in Scala, the file's package name doesn't have to match the directory name.

Where are SBT JARs?

All new SBT versions (after 0.7. x ) by default put the downloaded JARS into the . ivy2 directory in your home directory. If you are using Linux, this is usually /home/<username>/.


2 Answers

Figured out I just have to add them explicitly as unmanaged dependencies in Build.scala, they are not automatically pulled in from the lib folder. Adding this line to settings worked:

unmanagedJars in Compile += file("lib/vertica_jdk_5.jar")

like image 100
Garrett Hall Avatar answered Sep 28 '22 16:09

Garrett Hall


For a single project setup, putting jars into lib should work. If you have multi-project setup the lib directory would be under each subproject like app/lib.

like image 29
Eugene Yokota Avatar answered Sep 28 '22 15:09

Eugene Yokota