我有多个 SBT 项目,它们都有一个共同的设置 - 例如多模块、publishTo 设置等。
我如何提供每个项目都可以从中扩展的通用例如 CommonBuild 类?例如:
trait CommonBuild {
val publishSettings = Seq(
publishTo := Some("", ""),
credentials += ...
)
def module(name: String) (
settings: Seq[Setting[_]],
projectId: String = PROJECT + "-" + name,
dirName: String = name,
srcPath: String = PROJECT + name
) = Project(projectId, file(dirName), settings = (buildSettings ++ srcPathSetting(projectId, srcPath)) ++ publishSettings ++ settings)
}
现在它可以被项目构建使用:
object ProjABuild extends CommonBuild {
// use CommonBuild methods / vals
}
object ProjBBuild extends CommonBuild {
// use CommonBuild methods / vals
}