创建一个简单的任务

定义任务所需的只是声明它的类型和描述:

lazy val exampleTask = taskKey[Unit]("An example task that will return no value.")

因为 Unit 是类型,所以此任务完全由副作用组成。一旦定义,实施行动:

exampleTask := {
  val s: TaskStreams = streams.value
  s.log.info("The example task was executed.")
}

如果这些是在 build.sbt 中定义的,你可以加载项目并执行它:

> exampleTask
[info] The example task was executed.