13

As part of sbt-assembly I want to include both src and test class files in jar. Sbt-assembly includes only src files with dependencies. Is there any way through which I can include test classes also in same jar?

Anuj Mehta
  • 1,072
  • 3
  • 13
  • 25

1 Answers1

11

I wrote sbt-assembly so that the settings can be loaded into other configurations than the default Runtime. Put the following in assembly.sbt and it should add test:assembly task:

import AssemblyKeys._

Project.inConfig(Test)(baseAssemblySettings)

jarName in (Test, assembly) := s"${name.value}-test-${version.value}.jar"

Like the way jarName setting is scoped, substitute xxx in assembly in README with xxx in (Test, assembly) to customize the setting.

Eugene Yokota
  • 94,654
  • 45
  • 215
  • 319
  • 1
    Hi folks, I am having error: not found: object AssemblyKeys error when I run sbt test:assembly, any hint about how to solve this issues? – Rami Nov 03 '15 at 09:28
  • I had to follow the solution here instead to make this work: https://stackoverflow.com/a/34910525/1571826 – Def_Os Sep 06 '18 at 23:12