gpt4 book ai didi

sbt - 如何在 sbt 中的 project/Build.scala 中定义自定义任务?

转载 作者:行者123 更新时间:2023-12-04 14:46:31 24 4
gpt4 key购买 nike

project/Build.scala 中有以下任务声明, print当我输入 print 时无法识别任务在 SBT 控制台上。

lazy val print = task { println("print") }

怎么了?

最佳答案

您需要一个 TaskKey为此,可以使用 taskKey 进行实例化。宏:

lazy val printTask = taskKey[Unit]("print")

我建议看看相应的 documentation about tasks .
文档说:

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

关于sbt - 如何在 sbt 中的 project/Build.scala 中定义自定义任务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17141757/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com