Can't seem to find out how to do this very simple thing in SBT: I'd like to package (or pack/assemble/archive/copy) all of the dependencies needed to run tests. Ideally this would include all the dependency jars and the project classes jar in some tar/gz/zip, but simply copying them into a single folder so I can then easily zip them up would be great. All I've found so far is the ability to simply list the classpath ('show test:dependencyClasspath') but this leaves me having to write a script to copy or archive them. sbt-pack works great for the regular runtime classpath dependencies but couldn't get it to work with any test dependencies and had the same issue with sbt-assembly.
1 Answers
0
votes
If you want, you can reuse most parts of sbt-pack by overriding a few selected settings to refer to the test classpath.
In your build, add :
packSettings
packAllClasspaths <<= (thisProjectRef, buildStructure) flatMap getFromAllProjects(dependencyClasspath in Test),
packAllUnmanagedJars <<= (thisProjectRef, buildStructure, packExclude) flatMap getFromSelectedProjects(unmanagedJars in Test),
packLibJars <<= (thisProjectRef, buildStructure, packExclude) flatMap getFromSelectedProjects(packageBin in Test)
However, you will also need to copy those methods from sbt-pack code to make it work. This may not be exactly be the cleanest way to do it, but you avoid re-implementing the packaging process yourself.
IMO, your best bet would be use sbt-native-packager, which is more flexible on how you define your package and the file you put into it.