不同 sbt Key 操作符的用例 [英] Use cases for different sbt Key operators

查看:13
本文介绍了不同 sbt Key 操作符的用例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里似乎真的缺少 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 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

也就是说,@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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆