我想从任务中获取项目和配置轴。例如,考虑以下任务:
myTask := {
val project = ?
val configuration = ?
val key = ?
println(s"project: $project")
println(s"configuration: $configuration")
println(s"key: $key")
}
如果我像这样运行任务,
> myModule/myConfig:myTask
它应该打印
project: myModule
configuration: myConfig
key: myTask
答案 0 :(得分:0)
我在build.sbt
中的部分解决方案如下:
lazy val myTask = taskKey[Unit]("Prints axes of its execution")
lazy val myTaskSetting = myTask := {
val project = thisProject.value.id
val cfg = configuration.?.value
val key = myTask.key.label
println(s"project: $project")
println(s"configuration: $cfg")
println(s"key: $key")
}
myTaskSetting
lazy val a, b = project settings (Seq(myTaskSetting): _*)
我不知道如何访问任务在执行时绑定的当前配置。
> myTask
project: axes
configuration: None
key: myTask
project: b
configuration: None
key: myTask
project: a
configuration: None
key: myTask