Environment-specific distributions using sbt native packager

Viewed 755

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.

1 Answers
Related