Scrooge为sbt和maven提供了两个插件。我对maven插件并不感兴趣。
看来sbt插件具有从依赖工件中提取节俭文件的能力。参见scroogeThriftDependencies选项这里
然而,我仍然非常困惑这是如何工作,因为我已经添加了sbt插件到回购只有节俭的文件。我某种程度上希望插件发布一个工件,其中包含从生成的代码编译的类和节约源本身,这样依赖于它的库和定义它自己的节约就可以访问这个节约,以便编译它自己的节约。
我调查了我的构建所产生的工件,发现绝对没有任何节俭文件的痕迹。
有人知道这是怎么回事吗?maven插件是否发布节约资源,但此功能仅在消费端添加到sbt中?我是不是误解了别的什么?
发布于 2014-10-03 17:01:57
因此,这个特性从未在Scrooge的sbt插件中实现,即使它是为maven插件实现的。
我发布了一个公关来修复这个问题:https://github.com/twitter/scrooge/pull/153
发布于 2014-10-03 09:29:51
Scrooge SBT插件不涉及工件发布。你自己来处理吧。在包含您想要发布的IDL文件的项目中,将其添加到build.sbt中。
organization := "me"
name := "thrift-inherit-shared"
version := "0.1-SNAPSHOT"
scalaVersion := "2.10.4"
com.twitter.scrooge.ScroogeSBT.newSettings
lazy val thriftDirectory = settingKey[File]("The folder containing the thrift IDL files.")
thriftDirectory := {
baseDirectory.value / "src" / "main" / "thrift"
}
lazy val thriftIDLFiles = settingKey[Seq[File]]("The thrift IDL files.")
thriftIDLFiles := {
(thriftDirectory.value ** "*.thrift").get
}
// this makes sure the jar file will only contain the .thrift files and no generated classes
mappings in (Compile, packageBin) := {
thriftIDLFiles.value map { thriftFile => (thriftFile, thriftFile.name)}
}
libraryDependencies ++= Seq(
"org.apache.thrift" % "libthrift" % "0.9.1",
"com.twitter" %% "scrooge-core" % "3.16.3"
)通过sbt publish或sbt publishLocal将工件发布到回购中。然后,在另一个项目中,您的build.sbt可能如下所示:
organization := "me"
name := "thrift-inherit-server"
version := "0.1-SNAPSHOT"
scalaVersion := "2.10.4"
com.twitter.scrooge.ScroogeSBT.newSettings
scroogeThriftDependencies in Compile := Seq("thrift-inherit-shared_2.10")
libraryDependencies ++= Seq(
"me" %% "thrift-inherit-shared" % "0.1-SNAPSHOT",
"org.apache.thrift" % "libthrift" % "0.9.1",
"com.twitter" %% "scrooge-core" % "3.16.3"
)当您执行scroogeGen任务时,它将包括依赖的线程IDL。因此,您可能有这样一个.thrift文件,它将全部工作:
include "shared.thrift" <--- dependent IDL file
namespace java me.server.generated.thrift
struct UserEnvironment {
1: shared.Environment env <--- defined in dependent IDL file
2: i64 userId
}https://stackoverflow.com/questions/26026575
复制相似问题