SBT 0.13.8 what does the SettingKey.~= method do

2019-06-05 04:17发布

问题:

The SettingKey.~= method is used to exclude dependencies from libraryDependencies (see play 2.3.8 sbt excluding logback), but trying to find out what it does is hard as:

  1. There is no documentation about this function at http://www.scala-sbt.org/0.13.12/api/index.html#sbt.SettingKey,
  2. It cannot be searched using Google as it uses symbols in the method name and
  3. Examination of the SBT source code (https://github.com/sbt/sbt/blob/0.13/main/settings/src/main/scala/sbt/Structure.scala#L47) does not provide an obvious answer.

Can anyone shed light on what this does?

回答1:

someScopedKey ~= f

is equivalent to

someScopedKey := f(someScopedKey.value)

In other words, it transforms the previous value of the setting/task with a given function. That's literally all there is to know about it.