Reputation: 5728
Suppose there's something like this in build.sbt
val printMessage = taskKey[Unit]("Simple task")
printMessage := {
println("Hello")
}
How sbt figures out that this task is called printMessage
and makes it available in CLI when there is no string with that text? I would understand if the code was something like val printMessage = taskKey[Unit]("printMessage", "description")
but this really baffles me out
Upvotes: 4
Views: 86
Reputation: 2895
SBT has a macro, sbt.std.KeyMacro.taskKeyImpl
which takes a String
description and infers the task name from the defining val's name.
This macro is aliased to taskKey[T]
in the sbt package object.
So when you call taskKey[Unit]("SimpleTask")
, that's expanded to a macro that finds the val printMessage
and uses that to infer the task key's name.
Upvotes: 4