I'm new to sbt. I want it to put all the dependency jar
files as well as my jar file into one place. SBT will run the app, but I've got various dependencies scattered around and an .ivy
folder full of things my jar file depends on indirectly.
So Is there a simple command to copy them all into a single place so I can distribute it to another machine?
The libraryDependencies key Most of the time, you can simply list your dependencies in the setting libraryDependencies . It's also possible to write a Maven POM file or Ivy configuration file to externally configure your dependencies, and have sbt use those external configuration files.
If you have JAR files (unmanaged dependencies) that you want to use in your project, simply copy them to the lib folder in the root directory of your SBT project, and SBT will find them automatically.
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>/.
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.
There are many plugins you can use: sbt-assembly, sbt-proguard, sbt-onejar, xitrum-package etc.
See the list of SBT plugins.
Add the following line to your build.sbt
file.
retrieveManaged := true
This will gather the dependencies locally
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With