不同 sbt Key 操作符的用例 [英] Use cases for different sbt Key operators
问题描述
这里似乎真的缺少 sbt 的文档,所以我想得到一个明确的答案:+="、++="、<+="、<++=", 和 "<<=" 在 Keys 上操作时?
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 正确指出了除 +=
、++=<之外的所有运算符/code> 和
:=
已弃用.
You cannot find documentation, because as @JacekLaskowski correctly pointed out all operators except for +=
, ++=
and :=
are deprecated.
但是,您可以找到 Documentation 如果你切换到旧版本的 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 <<= name
,那么organization
值等于name
值.您可以依赖多个值,例如组织 <<= (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 Key 操作符的用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!