如何在 sbt 插件中定义 运行 任务
How to run task defined in sbt plugin
在我的项目中,我使用公开任务 genExport 的插件。我可以从控制台 运行 genExport 任务:
sbt genExport
我的问题是我无法在项目编译后将我的 sbt 项目配置为 运行 genExport:
lazy val sample:Project = project
.in(file("sample"))
.settings(
MyPluginKeys.someKey := "someKeyValue",
compile in Compile <<= (compile in Compile) map { x =>
println("----------")
// ???
x
}
)
.enablePlugins(MyPlugin)
从 sbt 文档中我无法了解如何通过名称从插件调用任务。我已经尝试过:
taskKey[Unit]("genExport").taskValue
没有任何成功。我错过了什么?
val genexport = TaskKey[Unit]("genExport")
和
genExport <<= genExport triggeredBy (compile in Compile)
在我的项目中,我使用公开任务 genExport 的插件。我可以从控制台 运行 genExport 任务:
sbt genExport
我的问题是我无法在项目编译后将我的 sbt 项目配置为 运行 genExport:
lazy val sample:Project = project
.in(file("sample"))
.settings(
MyPluginKeys.someKey := "someKeyValue",
compile in Compile <<= (compile in Compile) map { x =>
println("----------")
// ???
x
}
)
.enablePlugins(MyPlugin)
从 sbt 文档中我无法了解如何通过名称从插件调用任务。我已经尝试过:
taskKey[Unit]("genExport").taskValue
没有任何成功。我错过了什么?
val genexport = TaskKey[Unit]("genExport")
和
genExport <<= genExport triggeredBy (compile in Compile)