I'm trying to create/configure environment-specifc distributions (for development, quality and production) using the sbt native packager functionality available in Play (2.2). I tried to achieve this using the following settings in a build.sbt file:
val dev = config("dev") extend(Universal)
val qual = config("qual") extend(Universal)
val prod = config("prod") extend(Universal)
def distSettings: Seq[Setting[_]] =
inConfig(dev)(Seq(
mappings in Universal <+= (resourceDirectory in Compile) map { dir =>
println("dev")
(dir / "start.bat.dev") -> "bin/start.bat"
// additional mappings
}
)) ++
inConfig(qual)(Seq(
mappings in Universal <+= (resourceDirectory in Compile) map { dir =>
println("qual")
(dir / "start.bat.qual") -> "bin/start.bat"
// additional mappings
}
)) ++
inConfig(prod)(Seq(
mappings in Universal <+= (resourceDirectory in Compile) map { dir =>
println("prod")
(dir / "start.bat.prod") -> "bin/start.bat"
// additional mappings
}
))
play.Project.playScalaSettings ++ distSettings
In the SBT console, when I'm typing "dev:dist" I was expecting to see only "dev" as output and correspondingly only the corresponding mappings to be used. Instead, it looks like all mappings across all configs are merged. Most likely I don't understand how configs are supposed to work in SBT. In addition, there might be better approaches which achieve what I'm looking for.
inConfig(c)( settings )
means to use c
as the configuration when it isn't explicitly specified in settings
. In the example, the configuration for mappings
is specified to be Universal
, so the mappings are all added to the Universal
configuration and not the more specific one.
Instead, do:
inConfig(prod)(Seq(
mappings <+= ...
))
That is, remove the in Universal
part.
Note: because the more specific configurations like prod
extend Universal
they include the mappings from Universal
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With