Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8345393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:39:36+00:00 2026-06-09T06:39:36+00:00

I have a task lazy val task = TaskKey[Unit] that takes a lazy val

  • 0

I have a task lazy val task = TaskKey[Unit] that takes a lazy val setting = SettingKey[String] as input. I also have three different, independent config scopes (config("dev"), config("stage"), config("prod")) and a build.sbt file that specifies different values for setting for each of the config scopes (setting in stage := "foo" … ).

I expected that calling task using the config scope prefix would make the task use the values from the respective config scope (e.g. >dev:task would make the task use the setting values from dev, using command >stage:task would make the task use the setting values from stage, …). However, this does not seem to work.

How can I force task to use the settings from a specific config scope?

build.sbt:

setting := "default setting"

setting in stage := "stage setting"

setting in prod  := "prod setting"

Build.scala:

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 <<= setting map { s: String =>
    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)
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:39:37+00:00Added an answer on June 9, 2026 at 6:39 am

    I think you need to write something like

    val devTaskSetting = task <<= setting in dev map { s: String =>
       println("Setting in Dev is: " + s)
    }
    

    You can also define separate task keys, like this

    val devTask   = TaskKey[Unit]("task", "a simple task experiment") in dev
    val stageTask = TaskKey[Unit]("task", "a simple task experiment") in stage
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have task which takes a parameter and has three modes of results Example
I have task that involves creating the right design for the JSON string before
I have task involving reading SAS .xpt files using .NET. For that I'm using
I have a task to do, I need to take data that has been
I have a task that runs periodically 10 second. I do some picturebox refreshing
I have: Task Entity that holds a foreignkey to a Project Entity. In the
I have task schedule for backup directory list of wwwroot. For that I have
I have one task that is checking a url speed, but i want that
Say that I have two resources, Project and Task. A Project can have many
I have a Rails website with three tables: User, Task, and TaskInstance. The Task

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.