title: How to make a sbt task use a specific configuration scope?
body: <p>I have a task <code>lazy val task = TaskKey[Unit]</code> that takes a <code>lazy val setting = SettingKey[String]</code> as input. I also have three different, independent config scopes (<code>config("dev")</code>, <code>config("stage")</code>, <code>config("prod")</code>) and a <code>build.sbt</code> file that specifies different values for <code>setting</code> for each of the config scopes (<code>setting in stage := "foo"</code> ... ).</p>
  
  <p>I expected that calling <code>task</code> using the config scope prefix would make the task use the values from the respective config scope (e.g.  <code>&gt;dev:task</code> would make the task use the <code>setting</code> values from <code>dev</code>, using command <code>&gt;stage:task</code> would make the task use the <code>setting</code> values from <code>stage</code>, ...). However, this does not seem to work.</p>
  
  <p>How can I force <code>task</code> to use the settings from a specific config scope?</p>
  
  <p>build.sbt:</p>
  
  <pre><code>setting := "default setting"
  
  setting in stage := "stage setting"
  
  setting in prod  := "prod setting"
  </code></pre>
  
  <p>Build.scala:</p>
  
  <pre><code>import sbt._
  import Keys._
  
  object TaskBuild extends Build {
    val setting = SettingKey[String]("setting", "a simple string setting")
  
    val task = TaskKey[Unit]("task", "a simple task experiment")
  
    val taskTask = task &lt;&lt;= setting map { s: String =&gt;
      println("Setting is: " + s)
    }
  
    lazy val dev = config("dev") describedAs("dev environment settings")
    lazy val stage = config("stage") describedAs("stage environment settings")
    lazy val prod = config("prod") describedAs("prod environment settings")
  
    lazy val root = Project(
      "project",
       file("."),
       settings = Defaults.defaultSettings ++ Seq(taskTask)
    )
    .configs(dev, stage, prod)
  }
  </code></pre>