'Custom outputPath for sbt-assembly
I have multi-project Build.scala. Is there a way to place all jars generated by sbt-assembly in the root target directory?
For example, consider the following:
lazy val root = Project("root", file(".")).aggregate(hello)
lazy val hello = Project(id = "hello", base = file("hello"))
.settings(assemblySettings: _*)
As is, if I run sbt assembly, hello.jar would be placed in hello/target/<scala-version>/. Is possible instead to place it in /target/<scala-version>/?
I know it's possible to specify the outputPath I want by adding the following setting:
target in assembly := file("target/scala-2.11/")
Is there any way to make this more generic? For example, so it is not necessary to manually specify the scala version?
Solution 1:[1]
assemblyOutputPath in assembly := file("yourpath")
Solution 2:[2]
A small improvement on this answer. If you need to retain the file name that is generated by assembly plugin do it as below:
assembly / assemblyOutputPath := file(s"/path/to/jar/${(assembly/assemblyJarName).value}")
Solution 3:[3]
You can set assemblyOutputPath via cmd:
sbt 'set assemblyOutputPath in assembly := new File("/path/to/package.jar")' assembly
In case you need to set multiple options - just use spaces:
sbt 'set test in assembly := {}' 'set assemblyOutputPath in assembly := new File("/path/to/package.jar")' assembly
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | randomsearch |
| Solution 2 | Sibimon Sasidharan |
| Solution 3 | Val Tikhonov |
