Reputation: 1875
With the following task declaration in project/Build.scala
, the print
task is not recognised when I type in print
at an SBT console.
lazy val print = task { println("print") }
What's wrong?
Upvotes: 8
Views: 7212
Reputation: 83421
taskKey[Unit]("print") := println("print")
Then in your SBT console,
> print
print
In more complex code, you'll usually see keys separate from the settings.
val printTask = taskKey[Unit]("print")
printTask := println("print")
Upvotes: 3
Reputation: 4593
You need a TaskKey
for this to work that can be instantiated by using the taskKey
macro:
lazy val printTask = taskKey[Unit]("print")
I recommend having a look at the corresponding documentation about tasks. The documentation says:
The name of the val is used when referring to the task in Scala code. The string passed to the TaskKey method is used at runtime, such as at the command line
Upvotes: 7