添加 addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1") 到我的项目失败 "Unresolved Dependencies"

Adding addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1") to my project fails with "Unresolved Dependencies"

我正在尝试将我的 SBT project 发布到 mvnrepository。我按照这些链接中的说明操作:

http://www.scala-sbt.org/release/docs/Using-Sonatype.html,以及 https://github.com/xerial/sbt-pack

当我将 xerial sbt-sonatype 插件添加到我的 build.sbt 文件时:

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1")   

编译器给我以下错误:

UNRESOLVED DEPENDENCIES

org.xerial.sbt#sbt-sonatype;1.1 not found

Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn]      org.xerial.sbt:sbt-sonatype:1.1 (scalaVersion=2.11, sbtVersion=0.13)
[warn]
[warn]  Note: Unresolved dependencies path:
[warn]      org.xerial.sbt:sbt-sonatype:1.1 (scalaVersion=2.11, sbtVersion=0.13) (/richstat/build.sbt#L56-57)
[warn]        +- com.github.shafiquejamal:richstat_2.11:0.0.1

我的SBT版本是0.13,我用的是Scala 2.11。我怎样才能解决这个问题?谢谢!

您必须在 project/plugins.sbt 中添加插件,因为插件是 元项目 的依赖项,而不是您的 library/application.

检查 sbt 文档:Using Plugins

关于 sbt 版本和 Scala 版本:有用于编译项目代码的 Scala 版本(在你的情况下为 2.11),还有 sbt 本身使用的 Scala 版本。后者由sbt版本决定:sbt-0.13使用Scala 2.10,sbt-1.0使用Scala 2.12.

P.S。我建议您更新到 sbt-1.0.2:只需更改 project/build.properties 中的版本并使用 sbt-sonatype 2.0.