我正在尝试在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
答案 0 :(得分:1)
要在定义设置时使用.value
(例如foo := bar
),您需要将其包含在Def.setting
/ Def.task
/ Def.inputTask
中(或更多内容)高级案例Def.settingDyn
/ Def.taskDyn
/ Def.inputTaskDyn
)。
所以对你的情况来说:
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
???
}