TODO: add link [2759]
如果想使用另一个key的值,可以调用其.value
:
name := "hello"
version := "1.0"
scalaVersion := "2.11.0"
val mykey = settingKey[Int]("demo key")
mykey := 100
val hello = taskKey[Unit]("demo task")
hello := {println("Hello, world: " + mykey.value)}
运行sbt hello
将输出:
Hello, world: 100
value
- is a macro defined in sbt.std.MacroValue
Tasks and Settings both produce values that can be used in other tasks and settings. It’s very rare in sbt that a Task doesn’t return something to be used in other tasks. This design allows great flexibility and power when defining complex builds. It’s also drastically simplifies parallel building.
Thanks to: http://stackoverflow.com/a/25808809/342235