SBT - 在一个项目中使用两个版本的库? [英] SBT - using two versions of library in a single project?
问题描述
我有一个项目,其中包含为 Scalatest 1.x 编写的一系列测试,这些测试使用 ShouldMatchers
类,该类在 2.x 版中已弃用.展望未来,我想将版本 2 用于新测试,但这意味着我必须重构所有现有测试(我可以这样做,但需要一些时间).
I have a project with a bunch of tests written for Scalatest 1.x, which use the ShouldMatchers
class, which was deprecated in version 2.x. Going forward, I want to use version 2 for new tests, but this will mean I have to refactor all my existing tests (which I can do, but it'll take some time).
与此同时,SBT 有没有办法针对 Scalatest 1.x 编译现有类,以及针对 Scalatest 2.0 编译新类?
In the meantime, is there a way in SBT to compile existing classes against Scalatest 1.x, and new ones against Scalatest 2.0?
或者更一般地说,针对不同版本的库编译项目中的某些类到其他类?(我知道这可能是一个非常可怕的想法.)
Or more generally, compile some classes in a project against a different version of a library to other classes? (I'm aware that this might be quite a horrible idea.)
推荐答案
您可以创建两个相关的子项目,每个版本的 scala-test 一个.
You could create two dependent sub-projects, one for each version of scala-test.
lazy val root = project.in(file("."))
lazy val oldTests = project.in(file("old-tests"))
.dependsOn(root)
.settings(
libraryDependencies += "org.scalatest" %% "scalatest" % "1.9.1" % "test"
)
lazy val newTests = project.in(file("new-tests"))
.dependsOn(root)
.settings(
libraryDependencies += "org.scalatest" %% "scalatest" % "2.2.6" % "test"
)
这篇关于SBT - 在一个项目中使用两个版本的库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!