Scala 不推荐使用对象作用域中的方法t4ToTable4:不推荐使用sbt 0.10样式的DSL:

Scala 不推荐使用对象作用域中的方法t4ToTable4:不推荐使用sbt 0.10样式的DSL:,scala,sbt,Scala,Sbt,我试图在SBT中定义自定义任务。我写的代码是 lazy val slick = TaskKey[Seq[File]]("gen-tables") lazy val slickCodeGen = (sourceManaged, dependencyClasspath in Compile, runner in Compile, streams) map {(dir, cp, r, s) => .... } 我得到一个警告 warning: method t4ToTable4 in

我试图在SBT中定义自定义任务。我写的代码是

lazy val slick = TaskKey[Seq[File]]("gen-tables")
lazy val slickCodeGen = (sourceManaged, dependencyClasspath in Compile, runner in Compile, streams) map {(dir, cp, r, s) =>
     ....
}
我得到一个警告

warning: method t4ToTable4 in object Scoped is deprecated: The sbt 0.10 style DSL is deprecated: '(k1, k2) map { (x, y) => ... }' should now be '{ val x = k1.value; val y = k2.value }'.
See http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html
lazy val slickCodeGen = (sourceManaged, dependencyClasspath in Compile, runner in Compile, streams) map {(dir, cp, r, s) =>
因此,我根据警告中的建议更改了代码

val sourceManagedValue = sourceManaged.value
现在我得到一个错误

error: `value` can only be used within a task or setting macro, such as :=, +=, ++=, Def.task or Def.setting

要在定义设置(例如
foo:=bar
)时在外部使用
.value
,您需要将其包装在
Def.setting
/
Def.task
/
/
Def.inputAskdyn
/
Def.inputAskdyn
)中

因此,对于您的情况:

lazy val slickCodeGen = Def task {
  val dir = sourceManaged.value
  val cp = (dependencyClasspath in Compile).value
  val r = (runner in Compile).value
  val s = streams.value
  ???
}