Reputation: 925
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?
Upvotes: 37
Views: 27763
Reputation: 869
Add the following line to your build.sbt
file.
retrieveManaged := true
This will gather the dependencies locally
Upvotes: 14
Reputation: 41
May you looking for this sbt plugin: https://github.com/anvie/sbt-onedir-plugin
Upvotes: 0
Reputation: 21962
There are many plugins you can use: sbt-assembly, sbt-proguard, sbt-onejar, xitrum-package etc.
See the list of SBT plugins.
Upvotes: 19
Reputation: 692
You could also try SBT Native Packager: https://github.com/sbt/sbt-native-packager (sbt 0.7+)
This is still a WIP but will be used in Play Framework 2.2 in the coming weeks. With this, you can create standalone ZIP files, Debian packages (DEB), Windows installation packages (MSI), DMG, RPM, and so on.
Upvotes: 4
Reputation: 161
Try sbt-pack plugin https://github.com/xerial/sbt-pack, which collects all dependent jars in target/pack folder and also generates launch scripts.
Upvotes: 8
Reputation: 31176
The SBT docs have a list of "One Jar Plugins":
- sbt-assembly: https://github.com/sbt/sbt-assembly
- xsbt-proguard-plugin: https://github.com/adamw/xsbt-proguard-plugin
- sbt-deploy: https://github.com/reaktor/sbt-deploy
- sbt-appbundle (os x standalone): https://github.com/sbt/sbt-appbundle
- sbt-onejar (Packages your project using One-JAR™): https://github.com/sbt/sbt-onejar
Upvotes: 2
Reputation: 163
Create a task in your build file like this:
lazy val copyDependencies = TaskKey[Unit]("pack")
def copyDepTask = copyDependencies <<= (update, crossTarget, scalaVersion) map {
(updateReport, out, scalaVer) =>
updateReport.allFiles foreach {
srcPath =>
val destPath = out / "lib" / srcPath.getName
IO.copyFile(srcPath, destPath, preserveLastModified = true)
}
}
Add the Task to a Project like this:
lazy val HubSensors =
Project("HubSensors", file("HubSensors"), settings = shared ++ Seq(
copyDepTask,
resolvers ++= Seq(novusRels),
libraryDependencies ++= Seq(
jodatime
)
)) dependsOn(HubCameraVision, JamServiceProxy, HubDAL)
In the SBT console type:
project [Project Name]
pack
Upvotes: 11