Use cases for different sbt Key operators

前端 未结 3 1573
小蘑菇
小蘑菇 2021-02-04 03:53

The documentation for sbt seems to be really lacking here, so I\'d like to get a definitive answer on this: what is the difference between \"+=\", \"++=\", \"<+=\", \"<++=

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-04 04:51

    You cannot find documentation, because as @JacekLaskowski correctly pointed out all operators except for +=, ++= and := are deprecated.

    You can however find the Documentation if you switch to older version of sbt.

    If you however are stuck to older version, this is their meaning (via documentation):

    • += and ++= append to previous value, where first appends single element and next appends a Seq
    • ~= transforms value, e.g. you want to use value stored in a setting to get a new setting.
    • <<= depends on another key, for example if you call organization <<= name, then organization value is equal to name value. You can depend on multiple values, e.g. organization <<= (name, version) { (n, v) => /* do something with values */ }
    • <+= and <++= are appending with dependencies, like the append, but you can use another's setting value to compute new value

    Said that, @JacekLaskowski is right, and if you are using sbt 13.x or greater you should not have to use those operators in favours of macros.

提交回复
热议问题