How to include test classes and test dependencies in sbt asssembly

I need to pack my test classes, resources, and also check the dependencies using the sbt build.

This sbt-assembly question : including test classes did not help - test: assembly still did not create a jar with any of the desired classes.

Please note that my setup at the moment looks like this:

FooBuild.scala:

lazy val cucumberAssemblySettings = assemblySettings ++ Seq( mainClass in assembly := Some("cucumber.api.cli.Main"), jarName in assembly := "cucumber.jar", mergeStrategy in assembly := { case "application.conf" => MergeStrategy.concat case "logback.xml" => MergeStrategy.last case x => defaultMergeStrategy(x) } ) 

And this is about the foo-cucumber subproject:

 lazy val foo_cucumber = Project("foo-cucumber", file("foo-cucumber")) .settings(defaultSettings: _*) .settings(cucumberAssemblySettings: _*) .dependsOn( foo_test_server % "compile->compile;test->test", foo_test_utils % "compile->compile;test->test" ) 

even if I add (Test, assembly) to the settings above, I get only a jar (whose name is not specified, but the full name with the version) that does not contain test classes or dependencies, regardless of invoke sbt foo-cucumber/test:assembly or sbt foo-cucumber/assembly

How to get a jar that has everything (compile and test classes and dependencies)

+7
source share
2 answers

The key for a project with several modules is to set the settings this way:

 .settings(inConfig(Test)(cucumberAssemblySettings): _*) 

and then do not have in (Test, assembly) in the settings

+3
source

It doesn't seem to work anymore. SBT version 1.xx and build 0.14.8. Any suggestions?

-1
source

Source: https://habr.com/ru/post/980663/


All Articles