我希望测试编译操作将 src/test/resources 的内容放入 target/scala_2.8.1/test-classes。
原因是我使用 IntelliJ IDEA 运行 SBT,它在运行测试时将 test-classes 目录放在类路径中。
我的 logback-test.xml 文件(logback 日志框架的配置)位于 src/test/resources 中,并且在测试期间找不到。
我希望测试编译操作将 src/test/resources 的内容放入 target/scala_2.8.1/test-classes。
原因是我使用 IntelliJ IDEA 运行 SBT,它在运行测试时将 test-classes 目录放在类路径中。
我的 logback-test.xml 文件(logback 日志框架的配置)位于 src/test/resources 中,并且在测试期间找不到。
这不会直接回答您的问题,而是显示我使用的替代方案。
我添加了两个新任务:prepare
和test-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")
然后我为这些配置“运行前”SBT 操作。这需要idea-sbt-plugin。
我使用sbt-idea SBT 处理器来配置 IntelliJ 模块设置。这包括target/scala_2.8.1/[test-]resources
作为依赖项。
虽然可能有更好的方法来做到这一点,但只要没有其他东西覆盖,这应该可以正常工作testCompile
。只需将以下内容添加到您的项目定义中。
override lazy val testCompile = testCompileAction dependsOn task {
import sbt.Process._
"cp -R src/test/resources/* target/scala_2.8.1/test-classes" ! log
None
}
override lazy val testCompile = testCompileAction dependsOn copyTestResources
override def testResourcesOutputPath = testCompilePath