如何更改SBT放置测试资源的目录? [英] How can I change the directory into which SBT puts test resources?

查看:158
本文介绍了如何更改SBT放置测试资源的目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望test-compile操作将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 {

} dependsOn(compile,copyResources)描述为(编译main,复制主要资源。用于idea-sbt-plugin中的before-action)

lazy val testPrepare = task {

} dependsOn(testCompile,copyResources,copyTestResources)de scribedAs(编译主要和测试,复制所有资源。用于idea-sbt-plugin中的before-action)

然后我配置'之前'对这些进行'SBT操作。这需要 SBT处理器配置IntelliJ模块设置这包括 target / scala_2.8.1 / [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 logging 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.

这篇关于如何更改SBT放置测试资源的目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆