Created
September 14, 2017 08:11
-
-
Save sjednac/90b2737842880fbc5e9ef0fa89c9ca29 to your computer and use it in GitHub Desktop.
Override a task setting in an SBT command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lazy val person = settingKey[String]("Person to greet") | |
lazy val hello = taskKey[Unit]("Greet person") | |
// https://stackoverflow.com/q/14262798/1535738 | |
def greetEveryone = Command.command("greetEveryone") { state => | |
Seq("John", "Alice", "Bob").foreach { name => | |
val extracted = Project extract state | |
val newState = extracted.append(Seq(person := name), state) | |
Project.extract(newState).runTask(hello, newState) | |
} | |
state | |
} | |
lazy val root = (project in file(".")) | |
.settings( | |
person := "John", | |
hello := { | |
println(s"Hello ${person.value}") | |
}, | |
commands ++= Seq(greetEveryone) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment