Environment-specific distributions using the built-in sbt packer

I am trying to create / configure environment-specificc 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 parameters in the 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 type "dev: dist", I expected to see only "dev" as output and, accordingly, only the corresponding mappings to be used. Instead, it looks like all mappings in all configurations are combined. Most likely, I do not understand how configs should work in SBT. Also, there may be better approaches that achieve what I am looking for.

+6
source share
1 answer

inConfig(c)( settings ) means using c as a configuration if it is not explicitly specified in settings . In this example, the configuration for mappings is listed as Universal , so all mappings are added to the Universal configuration, and not more specific.

Instead, run:

 inConfig(prod)(Seq( mappings <+= ... )) 

That is, delete the in Universal part.

Note: since more specific configurations such as prod extend Universal , they include mappings from Universal .

+2
source

All Articles