How can I change the directory into which SBT puts test resources?
I want the test-compile action to put the contents of src/test/resources into target/scala_2.8.1/test-classes.
The reason for this is that I'm running SBT with IntelliJ IDEA, which puts the test-classes directory on the classpath when it runs tests.
My logback-test.xml file (configuration for logback loggin开发者_开发问答g framework) lives in src/test/resources, and it's not being found during testing.
This doesn't directly answer your question, but instead shows an the alternative that I use.
I add two new tasks: prepare
and 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")
I then configure the 'before run' SBT action to these. This requires the idea-sbt-plugin.
I use the sbt-idea SBT Processor to configure the IntelliJ module setup. This includes target/scala_2.8.1/[test-]resources
as a dependency.
While there might be a better way of doing it, this should work as well as long as nothing else overrides testCompile
. Just add the following into your project definition.
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
精彩评论