用于单独构建和测试的 SBT 依赖管理

SBT dependency management for build and test separetly

我需要在 build.sbt 文件中添加依赖项,但这只会在 运行 我的回归测试时使用。有没有办法为构建、测试或回归测试指定库依赖性?

供您参考我的项目结构为

MyProject
 - app
 - conf
 - logs
 - target
 - test
 - test-regression
 - build.sbt

现在我在构建文件中将依赖项定义为

libraryDependencies ++= Seq( .... )

这就是你所说的 specs2 应该只在测试期间包含的方式:

libraryDependencies ++= Seq(specs2 % Test)

根据手册:

(...) means that specs2 will only be on the test classpath and it isn't needed by the main sources.

这里有描述:Per-configuration dependencies但是你必须深入研究如何让它更通用。