sbt:图书馆应该如何依赖scala-actors?

时间:2013-04-24 01:59:42

标签: scala sbt

我们有一个使用scala-actors 2.10.x的内部库。它在build.sbt

中有这个
libraryDependencies <++= scalaVersion(v =>
  Seq("org.scala-lang" % "scala-actors" % v)
)

这个库只用2.10.0编译并推送到我们的内部Maven仓库。

我们的一个依赖于库的项目已更新为2.10.1。依赖项目具有相同的libraryDependencies,因此编译依赖项目现在警告:

$ sbt
[info] Loading project definition from /tmp/foo/project
[info] Set current project to bar (in build file:/tmp/foo/)
[warn] Potentially incompatible versions of dependencies of {file:/tmp/foo/}bar:
[warn]    org.scala-lang: 2.10.1, 2.10.0

使用依赖sbt插件显示:

[info]   +-com.example:ourlibrary_2.10:1.0.1 [S]
[info]   | +-org.scala-lang:scala-actors:2.10.0 (evicted by: 2.10.1)
[info]   |
[info]   +-org.scala-lang:scala-actors:2.10.1 [S]

如何最好地编写图书馆的libraryDependencies?我有以下内容,但有更清洁的方式吗?

libraryDependencies <++= scalaVersion(v =>
  {
    // Use any version of scala-actors for this version of Scala.
    val split = v.split('.')
    val major = split(0).toInt
    val minor = split(1).toInt
    val revision = "[%s.%s,%s.%s)".format(major, minor, major, minor+1)
    Seq("org.scala-lang" % "scala-actors" % revision)
  }
)

1 个答案:

答案 0 :(得分:1)

Scala 2.10.x保证与二进制兼容,所以无论你做什么都没关系。常春藤似乎正确地逐出org.scala-lang:scala-actors:2.10.0,所以不应该造成任何问题。

事实上,您提到的警告消息被视为错误#709,并且不应在最新版本的sbt 0.12和0.13中显示。