不同 sbt 关键操作符的用例 [英] Use cases for different sbt Key operators
问题描述
sbt 的文档在这里似乎真的很缺乏,所以我想得到一个明确的答案:+="、++="、<+="、<+="之间有什么区别?"<++=", 和 "<<=" 操作键时?
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 "+=", "++=", "<+=", "<++=", and "<<=" when operating on Keys?
推荐答案
您找不到文档,因为@JacekLaskowski 正确指出了除 +=
之外的所有运算符,++=
和 :=
已弃用.
You cannot find documentation, because as @JacekLaskowski correctly pointed out all operators except for +=
, ++=
and :=
are deprecated.
然而,您可以找到 文档 如果您切换到旧版本的 sbt.
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):
+=
和++=
附加到前一个值,其中首先附加单个元素,然后附加一个Seq
~=
转换值,例如您想使用设置中存储的值来获取新设置.<<=
依赖于另一个键,例如如果你调用organization<<=名称
,那么organization
值等于name
值.您可以依赖多个值,例如organization <<= (name, version) { (n, v) =>/* 用值做一些事情 */}
<+=
和<++=
是 附加依赖,与附加类似,但您可以使用另一个设置值来计算新值
+=
and++=
append to previous value, where first appends single element and next appends aSeq
~=
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 callorganization <<= name
, thenorganization
value is equal toname
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
说,@JacekLaskowski 是对的,如果您使用 sbt 13.x 或更高版本,则不必使用这些运算符来支持宏.
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.
这篇关于不同 sbt 关键操作符的用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!