如何修改任务中的状态(如命令那样)?

时间:2016-01-04 20:51:21

标签: scala sbt

我有一项任务,我希望修改状态,以便下次调用该属性时设置。我知道使用Command这很容易,但我想知道如何在Task中执行此操作。

val myKey = AttributeKey[String]("my-key")

val getAttr = TaskKey[Unit]("get-attr")

val getAttrTask = getAttr <<= (state) map { (st) => 
  println(st.get(myKey))
  val newState = st.put(myKey, "hi")
  //How do I use the newState for the subsequent call?
}

打印:

> get-attr //=> None 
> get-attr //=> Some("hi")

1 个答案:

答案 0 :(得分:0)

tl; dr 无法在任务中更改[info] starting up engines, v4.8.1 [info] populating base path: map.osrm [info] HSGR file: "map.osrm.hsgr" [info] loading graph data [info] loading graph from map.osrm.hsgr [info] number_of_nodes: 13257636, number_of_edges: 91420598 [info] loaded 13257636 nodes and 91420598 edges [info] Data checksum is 2360151423 [info] loading edge information [info] loading core information [info] loading geometries [info] loading r-tree [info] loading timestamp [info] Loading Timestamp [info] loading street names [info] loaded plugin: table [info] loaded plugin: hello [info] loaded plugin: locate [info] loaded plugin: nearest [info] loaded plugin: match [info] loaded plugin: timestamp [info] loaded plugin: viaroute [info] loaded plugin: trip [info] http 1.1 compression handled by zlib version 1.2.8 [warn] [exception] bind: Address already in use 。使用命令。