如何更改 SBT 放置测试资源的目录?

Dav*_*vid 5 scala intellij-idea sbt

我希望测试编译操作将 src/test/resources 的内容放入 target/scala_2.8.1/test-classes 中。

原因是我使用 IntelliJ IDEA 运行 SBT,它在运行测试时将 test-classes 目录放在类路径上。

我的 logback-test.xml 文件(logback 日志框架的配置)位于 src/test/resources 中,但在测试过程中未找到它。

ret*_*nym 4

这并没有直接回答您的问题,而是显示了我使用的替代方案。

我添加了两个新任务:preparetest-prepare

lazy val prepare = task{
  None
} dependsOn (compile, copyResources) describedAs ("Compiles main, copies main resources. Use for the before-action in the idea-sbt-plugin")

lazy val testPrepare = task{
  None
} dependsOn (testCompile, copyResources, copyTestResources) describedAs ("Compiles main and test, copies all resources. Use for the before-action in the idea-sbt-plugin")
Run Code Online (Sandbox Code Playgroud)

然后,我将“运行前”SBT 操作配置为这些。这需要idea-sbt-plugin

替代文本

我使用sbt-idea SBT 处理器来配置 IntelliJ 模块设置。这包括target/scala_2.8.1/[test-]resources作为依赖项。

替代文本