答案 0 :(得分:1)
注意以下是SBT的相同配置 0.12 和sbt-thrift 0.6
我使用SBT 0.13.1 ,因此必须使用http://bigtoast.github.io/repo/com/github/bigtoast/sbt-thrift_2.10_0.13/0.7/中的sbt-thrift
0.7 。
<强>项目/ plugins.sbt 强>
resolvers += "bigtoast-github" at "http://bigtoast.github.com/repo/"
addSbtPlugin("com.github.bigtoast" % "sbt-thrift" % "0.7")
<强> build.sbt 强>
import com.github.bigtoast.sbtthrift.ThriftPlugin
seq(ThriftPlugin.thriftSettings: _*)
使用上面的构建配置,您可能需要查看https://github.com/bigtoast/sbt-thrift/blob/master/src/main/scala/ThriftPlugin.scala可能的任务和设置(我还没有检查README.md是否完全正确)。
设置“thrift文件的源目录source-directory
设置。默认为src / main / thrift”。
> thrift:source-directory
[info] C:\dev\sandbox\thrift\src\main\thrift
要更改值,请使用以下内容:
ThriftPlugin.thriftSourceDir := sourceDirectory.value / "my-own-source-dir"
和reload
因此设置会相应更改( react ):
> thrift:source-directory
[info] C:\dev\sandbox\thrift\src\my-own-source-dir\main\thrift
请注意,所有设置和任务都属于thrift
配置。
<强>项目/ plugins.sbt 强>
resolvers += "bigtoast-github" at "http://bigtoast.github.com/repo/"
addSbtPlugin("com.github.bigtoast" % "sbt-thrift" % "0.6")
由于OP询问了多项目构建配置,下面是两个项目的定义,其中一个项目配置了thriftSourceDir
的自定义值。
<强>项目/ MyBuild.scala 强>
import sbt._
import Keys._
import com.github.bigtoast.sbtthrift.ThriftPlugin._
object MyBuild extends Build {
lazy val thriftS = Defaults.defaultSettings ++
thriftSettings ++
Seq(
thriftSourceDir <<= sourceDirectory(_ / "my-own-source-dir")
)
lazy val thriftP = Project("thriftProject",
file("."),
settings = thriftS
)
lazy val someP = Project("some-other-project",
file("some-other-project")
)
}
使用构建配置,sbt shell为您提供以下内容:
> sbt-version
[info] 0.12.4
> projects
[info] In file:/Users/jacek/sandbox/so/thrift-0.12/
[info] some-other-project
[info] * thriftProject
> thrift:source-directory
[info] /Users/jacek/sandbox/so/thrift-0.12/src/my-own-source-dir/main/thrift
> thriftProject/thrift:source-directory
[info] /Users/jacek/sandbox/so/thrift-0.12/src/my-own-source-dir/main/thrift
> some-other-project/thrift:source-directory
[info] /Users/jacek/sandbox/so/thrift-0.12/some-other-project/src