sbt Tasks Create a Simple Task

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

All that is needed to define a task is a declaration of it's type and a description:

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

Because Unit is the type, this task is composed entirely of side-effects. Once defined, to implement actions:

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

If these are defined in build.sbt, you can load the project and execute it:

> exampleTask
[info] The example task was executed.


Got any sbt Question?