Steve
Steve

Reputation: 4668

issue with implementation of sbt from tutorial

I am running through the SBT: The Missing Tutorial to get a better understanding of sbt. In the Writing your own tasks part of the tutorial the following code was written:

gitCommitCountTask := {
  val branch = Process("git symbolic-ref -q HEAD").lines.head.replace("refs/heads/","")
  val commitCount = Process(s"git rev-list --count $branch").lines.head
  println(s"total number of commits on [$branch]: $commitCount")
  commitCount
}

There is no clear indication of which directory or file this code should be added to. Can anyone point me in the right direction. Thanks

Upvotes: 0

Views: 30

Answers (1)

laughedelic
laughedelic

Reputation: 6460

The text above this code says:

Creating a custom task is a two step process:

  • You have to define a TaskKey for your task
  • You have to provide the task definition

To write our task we will first write gitCommitCountTask taskKey in the build.sbt file

So both the task key and the task definition should be placed in the build.sbt file in the root of your project.

Upvotes: 1

Related Questions