我想为每个部署编译不同的配置文件 我无法使用vm选项,例如
-Dconfig.file = test.conf
。如何定义任务,例如:
sbt assemblyLocal
将使用配置文件
src / main / resources / local.conf
对于生产,我可以简单地运行
sbt组装
将使用默认的application.conf
吗?
答案 0 :(得分:0)
我不确定如何执行新任务,但是您可以定义其他配置并像(48*48*3)
和sbt prod:assembly
那样运行它们:
sbt local:assembly
还有您自己的MergeStrategy,该文件将文件重命名为application.conf:
lazy val Prod = config("prod") extend(Compile) describedAs("scope to build production packages")
lazy val Local = config("local") extend(Compile) describedAs("scope to build staging packages")
val root = (project in file(".")).configs(Prod, Local)
.settings(inConfig(Local)(Classpaths.configSettings ++ Defaults.configTasks ++ baseAssemblySettings ++Seq(
assemblyJarName := "local.jar",
assemblyMergeStrategy in assembly := {
case PathList("local.conf") => MergeStrategy.discard
case x =>
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
}
))).settings(inConfig(Prod)(Classpaths.configSettings ++ Defaults.configTasks ++ baseAssemblySettings ++ Seq(
assemblyJarName := "prod.jar",
assemblyMergeStrategy in assembly := {
case PathList("application.conf") => MergeStrategy.discard
case PathList("local.conf") => new MyMergeStrategy()
case x =>
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
}
)))
有关更多信息,您可以参考本文: http://eed3si9n.com/4th-dimension-with-sbt-013 或者这个stackoverflow答案: Multiple executable jar files with different external dependencies from a single project with sbt-assembly