我有一个包含scalania
主项目以及exercises
(answers
子)项目的多项目构建。
scalania 项目托管在 GitHub 上。
我正在尝试设置一个 SBT 项目配置,其中测试类是项目的一部分,exercises
而answers
项目提供解决方案。
我在 SBT 的官方文档中阅读了Per-configuration classpath dependencies并最终在scalania
主项目中得到以下配置:
lazy val exercises = project
lazy val answers = project.dependsOn(exercises % "test->test")
它似乎不起作用,在test
执行时我曾经得到:
> project answers
[info] Set current project to scalania-answers (in build file:/Users/jacek/oss/scalania/)
> test
[info] Passed: Total 0, Failed 0, Errors 0, Passed 0
[info] No tests to run for answers/test:test
[success] Total time: 1 s, completed Oct 27, 2013 1:06:51 AM
直到我更改answers/build.sbt
为以下内容:
scalaSource in Test := (scalaSource in LocalProject("exercises") in Test).value
它现在工作正常。
> reload
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Loading project definition from /Users/jacek/oss/scalania/project
[info] Set current project to scalania-answers (in build file:/Users/jacek/oss/scalania/)
> project answers
[info] Set current project to scalania-answers (in build file:/Users/jacek/oss/scalania/)
> testOnly *s99.P01*
[info] Formatting 19 Scala sources {file:/Users/jacek/oss/scalania/}answers(test) ...
[info] Compiling 19 Scala sources to /Users/jacek/oss/scalania/answers/target/scala-2.10/test-classes...
[info] P01Spec
[info]
[info] P01 solution should
[info] + Find the last element of a list
[info]
[info]
[info] Total for specification P01Spec
[info] Finished in 151 ms
[info] 1 example, 0 failure, 0 error
[info] Passed: Total 1, Failed 0, Errors 0, Passed 1
[success] Total time: 74 s, completed Oct 27, 2013 1:09:07 AM
只使用有什么问题project.dependsOn(exercises % "test->test")
?我在构建配置中遗漏了什么吗?