SBT - using two versions of library in a single project?

可紊 提交于 2019-12-12 03:45:48

问题


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).

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.)


回答1:


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"
  )


来源:https://stackoverflow.com/questions/36861292/sbt-using-two-versions-of-library-in-a-single-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!