即使我有不匹配的条件来运行它,SBT也会评估输入任务

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了即使我有不匹配的条件来运行它,SBT也会评估输入任务相关的知识,希望对你有一定的参考价值。

这是我的代码:

run in Compile := { true match {
    case true => (run in Compile).evaluated
    case false => (run in Compile).evaluated
}}

并输出:

> run
[info] Running Main 
[info] Running Main 
Main.main
Main.main

我希望SBT只评估一次(run in Compile)!但它运行了两次!为什么!我错过了什么吗?

答案

我的错!宏的行为是对的!我必须使用taskDyn来定义我的任务:https://www.scala-sbt.org/1.x/docs/Tasks.html#Dynamic+Computations+with

以上是关于即使我有不匹配的条件来运行它,SBT也会评估输入任务的主要内容,如果未能解决你的问题,请参考以下文章