从0.13.x升级到SBT 1.x.x时,如何解决各种“ Append.Value [...]没有隐式”错误?

时间:2019-06-13 19:55:06

标签: scala sbt

从0.13.7迁移后,我正在使用SBT 1.2.8;使用的旧变体例如以<+=代替+=,例如unmanagedClasspath in Compile += baseDirectory map { bd => Attributed.blank(bd / ".." / "config") },,但已删除此类运算符。

我看到了其他一些相关问题,但是所涉及的类型似乎相差很大,对我无济于事:

  1. No implicit for Append.Value[...] found with Def.task to generate files in SBT 0.13?
  2. sbt: No implicit for Append.Value[Seq[java.io.File], sbt.Def.Initialize[java.io.File]] found,

文件中三个相关的连续行是:

  unmanagedClasspath in Compile += baseDirectory map { bd => Attributed.blank(bd / ".." / "config") },
  unmanagedClasspath in Runtime ++= (unmanagedClasspath in Compile),
  unmanagedClasspath in Test ++= (unmanagedClasspath in Compile),

这会产生以下错误:

build.sbt:70: error: No implicit for Append.Value[sbt.Keys.Classpath, sbt.Def.Initialize[sbt.Task[sbt.internal.util.Attributed[java.io.File]]]] found,
  so sbt.Def.Initialize[sbt.Task[sbt.internal.util.Attributed[java.io.File]]] cannot be appended to sbt.Keys.Classpath
  unmanagedClasspath in Compile += baseDirectory map { bd => Attributed.blank(bd / ".." / "config") },
                                ^
build.sbt:71: error: No implicit for Append.Values[sbt.Keys.Classpath, sbt.TaskKey[sbt.Keys.Classpath]] found,
  so sbt.TaskKey[sbt.Keys.Classpath] cannot be appended to sbt.Keys.Classpath
  unmanagedClasspath in Runtime ++= (unmanagedClasspath in Compile),
                                ^
build.sbt:72: error: No implicit for Append.Values[sbt.Keys.Classpath, sbt.TaskKey[sbt.Keys.Classpath]] found,
  so sbt.TaskKey[sbt.Keys.Classpath] cannot be appended to sbt.Keys.Classpath
  unmanagedClasspath in Test ++= (unmanagedClasspath in Compile),

如果这还不够,请使用full build.sbt,稍后将很高兴在内联相关位。

1 个答案:

答案 0 :(得分:0)

斜视一下之后,我终于可以解决此问题,并进行以下更改。在每种情况下,关键是要识别在哪里访问所讨论的.value

  unmanagedClasspath in Compile += baseDirectory.value / ".." / "config",
  unmanagedClasspath in Runtime ++= (unmanagedClasspath in Compile).value,
  unmanagedClasspath in Test ++= (unmanagedClasspath in Compile).value,

除了以上链接之外,以下文档似乎对您有所帮助: -https://www.scala-sbt.org/1.0/docs/Tasks.html