Finagle + Thriftのbuild.sbt
またSBT関連でハマったのでメモ。
Finagle使ってThriftサーバーを立てようとしてつまづいた。
FinagleのThrift Server Sampleにscrooge-sbt-pluginを使うと書いてある。
thriftファイルを書いてビルドすればtarget/の中にjarを作成してくれる代物。
GitHub参考に以下で設定。
plugins.sbt
addSbtPlugin("com.twitter" %% "scrooge-sbt-plugin" % "3.9.2")
build.sbt
com.twitter.scrooge.ScroogeSBT.newSettings
libraryDependencies ++= Seq(
"org.apache.thrift" % "libthrift" % "0.8.0",
"com.twitter" %% "scrooge-core" % "3.9.2",
"com.twitter" % "finagle-thrift_2.10" % "6.13.1"
)
ほんで、この設定でビルドしようとすると・・・
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.twitter#scrooge-sbt-plugin;3.9.2: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] com.twitter:scrooge-sbt-plugin:3.9.2 (sbtVersion=0.13, scalaVersion=2.10)
.
.
.
調べるとSBTのバージョンが0.13というのがダメらしい。
どんどんSBTが嫌いになる今日この頃。
まあ、それは置いておいてSBTのバージョン設定を下げよう。
project/直下にbuild.propertiesファイルを作成。
build.properties
sbt.version = 0.12.2
これでOK。
あと、pluginsで見に行くリポジトリを追加しておく。
plugins.sbt
resolvers += "sonatype" at "https://oss.sonatype.org/content/groups/public"
addSbtPlugin("com.twitter" %% "scrooge-sbt-plugin" % "3.9.2")
とりあえずこれでビルドは通った。
2014/04/21追記
thriftファイルはsrc/main/thrift/直下が標準になっているのでそこにファイルを置く。
そうすればSBTのcompile時にtarget/scala-2.10/src_managed/main/配下に指定のnamespaceで出力されます。