【发布时间】:2021-04-09 14:30:18
【问题描述】:
我正在为 SBT 编写一个插件,它将生成从 Scala 程序创建 Azure 函数所需的配置文件。我的工作在 github (https://github.com/code-star/sbt-azure-functions-plugin/tree/develop) 上,并且可以在自述文件中阅读,我想在用户发出 sbt azfunCreateZipFile 时自动触发 assembly 任务。
我的插件的用户,可以通过将以下行添加到他们的build.sbt:
azfunCreateZipFile := (azfunCreateZipFile dependsOn assembly).value
我希望该任务连接已包含在我的插件定义中。我该怎么做?
我知道通过在任务定义中使用otherTask.value 可以使任务依赖于其他任务,所以我尝试在azfunCreateZipFile 任务定义中添加这样一行(参见./plugin/src/main/scala/sbtazurefunctions/AzureFunctions.scala):
azfunGenerateFunctionJsons := {
// depend on assembly step
val _ = assembly.value
... <actual task definition code>
azfunTargetFolder.value
}
然后我得到一个错误,即找不到程序集:
[IJ]sbt:root> compile
[info] Compiling 1 Scala source to /home/jml/work/scala/azure/sbt-azure-functions- plugin/plugin/target/scala-2.12/sbt-1.0/classes ...
[error] /home/jml/work/scala/azure/sbt-azure-functions-plugin/plugin/src/main/scala/sbtazurefunctions/AzureFunctions.scala:113:15: not found: value assembly
[error] val _ = assembly.value
[error] ^
[error] one error found
[error] (plugin / Compile / compileIncremental) Compilation failed
[error] Total time: 1 s, completed Jan 3, 2021, 4:41:56 PM
[IJ]sbt:root>
我尝试了很多导入,但没有一个成功:
import sbtassembly.AssemblyPlugin._ (and variations using AssemblyKeys and the AutoImport object)
import sbt.Keys._
我能做些什么来解决这个问题?
【问题讨论】:
标签: scala sbt sbt-plugin