具有依赖关系的Sbt任务

时间:2012-02-15 15:16:51

标签: scala sbt

我正在阅读sbt tutorial,我想了解依赖于其他任务的任务部分。问题是,我从该教程创建了以下内容,但它不起作用:

import sbt._
import Keys._
import sys.process._

object HelloBuild extends Build {
  val hwsettings = Defaults.defaultSettings ++ Seq (
    scalaVersion := "2.9.1",
    name := "sbt-build"
  )
  val intt = TaskKey[Int]("int-task")
  val intTask = intt := 1
  val sample = TaskKey[Int]("sample-task")
  val sampleTask = sample <<= intTask map { _ + 1 }

  lazy val project = Project (
    "project",
    file("."),
    settings = hwsettings ++ Seq(intTask)
  )
}

它说:

[error] /home/platon/Tor/sbt-build/project/Build.scala:21: type mismatch;
[error]  found   : Int(1)
[error]  required: String
[error]   val sampleTask = sample <<= intTask map { _ + 1 }

我做错了什么?

1 个答案:

答案 0 :(得分:3)

从任务键intt开始;不是该任务键的初始化。

val sampleTask = sample <<= intt map { _ + 1 }