如何使用sbt 0.13的sbt-scalabuff插件?

时间:2013-12-12 21:27:15

标签: scala sbt protocol-buffers

我正在尝试使用sbt-scalabuff plugin,但是sbt一直在抱怨无法找到该插件。

插件文档也没有说明解析器网址。该插件是否已弃用或我的Scala版本不受支持?

详细说明:

com.github.sbt:sbt-scalabuff:0.2 (sbtVersion=0.13, scalaVersion=2.10)

这是我的plugins.sbt

libraryDependencies += "net.sandrogrzicic" %% "scalabuff-runtime" % "1.3.6"

addSbtPlugin("com.github.sbt" %% "sbt-scalabuff" % "0.2")

这是堆栈跟踪的一部分:

sbt.ResolveException: unresolved dependency: com.github.sbt#sbt-scalabuff;0.2: not found
    at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:213)
    at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:122)
    at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:121)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:116)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:116)
    at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:104)
    at sbt.IvySbt.sbt$IvySbt$$action$1(Ivy.scala:51)
    at sbt.IvySbt$$anon$3.call(Ivy.scala:60)
    ...
[error] (*:update) sbt.ResolveException: unresolved dependency: com.github.sbt#sbt-scalabuff;0.2: not found

1 个答案:

答案 0 :(得分:5)

The sbt-scalabuff plugin没有将插件jar发布到sbt可用于您的配置的任何已知存储库 - sbtVersion=0.13scalaVersion=2.10

我也怀疑插件是否支持sbt 0.13(当我自己编译插件以使用该版本时,我的几次尝试都失败了。)

您似乎唯一的选择是将sbt降级为0.12.4或将插件迁移到0.13

由于插件已发布到Resolver.sbtPluginRepo("releases")存储库,即http://repo.scala-sbt.org/scalasbt/sbt-plugin-releaseshttp://dl.bintray.com/sbt/sbt-plugin-releases/com.github.sbt/sbt-scalabuff/scala_2.10/sbt_0.12/,因此您必须使用sbt版本。

project/sbt-scalabuff.sbt中使用以下内容:

addSbtPlugin("com.github.sbt" %% "sbt-scalabuff" % "0.2")

然后,您应该在project/build.properties中指定sbt的版本,如下所示:

sbt.version=0.12.4

或只使用sbt-launch 0.12.4

在sbt控制台中,您可以使用scalabuff任务或设置:scalabuff-versionscalabuff-mainscalabuff-args

> sbt-version
[info] 0.12.4
> about
[info] This is sbt 0.12.4
[info] The current project is {file:/Users/jacek/sandbox/sbt-scalabuff-test-project/}main
[info] The current project is built against Scala 2.9.2
[info] Available Plugins: org.sbtidea.SbtIdeaPlugin, com.timushev.sbt.updates.UpdatesPlugin, scalabuff.ScalaBuffPlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.9.2
> scalabuff-version
[info] 1.1.1
> help scalabuff
Generate Scala sources from protocol buffers definitions
> scalabuff-args
[info] List()
> scalabuff-main
[info] net.sandrogrzicic.scalabuff.compiler.ScalaBuff

请参阅GitHub存储库中的scalabuff.ScalaBuffPlugin对象。

我还必须更改构建对象(如the Usage section中所述)以设置带有import sbt._插件的项目:

import sbt._
import scalabuff.ScalaBuffPlugin._

object build extends Build {
  lazy val root = Project(
    "main",
    file("."),
    settings = Defaults.defaultSettings ++ scalabuffSettings
  ).configs(ScalaBuff)
}