Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何临时跳过在自定义sbt命令中运行编译任务?_Sbt - Fatal编程技术网

如何临时跳过在自定义sbt命令中运行编译任务?

如何临时跳过在自定义sbt命令中运行编译任务?,sbt,Sbt,在快速安装命令(在我编写的sbt插件中定义)中运行包任务时,我试图暂时跳过编译任务。通过将skip设置置于compile任务上,我可以跳过所有编译,但这会导致跳过所有compile任务: object MyPlugin extends Plugin { override lazy val settings = Seq( (skip in compile) := true ) ... } 我只需要在运行快速安装命令时跳过编译。是否有方法临时修改设置,或

快速安装
命令(在我编写的sbt插件中定义)中运行
任务时,我试图暂时跳过编译任务。通过将
skip
设置置于
compile
任务上,我可以跳过所有编译,但这会导致跳过所有
compile
任务:

  object MyPlugin extends Plugin {
    override lazy val settings = Seq(
      (skip in compile) := true
    )
    ...
  }
我只需要在运行
快速安装
命令时跳过
编译
。是否有方法临时修改设置,或仅将其范围设置为“快速安装”命令

我尝试了设置转换(基于),该转换应将
skip:=false
的所有实例替换为
skip:=true
,但没有任何效果(即转换后仍会进行编译):

知道我遗漏了什么和/或更好的方法吗

编辑:

跳过设置是一项任务,因此简单的解决方法是:

object SbtQuickInstallPlugin extends Plugin {
  private lazy val installCommand =  Command.args("quick-install", "quick install that skips compile step")(doCommand(Configurations.Compile))

  private var shouldSkipCompile = false  // by default, don't skip compiles

  override lazy val settings = Seq(
    commands ++= Seq(installCommand),
    (Keys.skip in compile) := shouldSkipCompile
  )

  def doCommand(configs: Configuration*)(state: State, args: Seq[String]): State = {
    shouldSkipCompile = true // start skipping compiles

    ... // do stuff that would normally trigger a compile such as running the packageBin task

    shouldSkipCompile = false // stop skipping compiles
  }
}
我不相信这是最可靠的解决方案,但它似乎满足了我的需要

object SbtQuickInstallPlugin extends Plugin {
  private lazy val installCommand =  Command.args("quick-install", "quick install that skips compile step")(doCommand(Configurations.Compile))

  private var shouldSkipCompile = false  // by default, don't skip compiles

  override lazy val settings = Seq(
    commands ++= Seq(installCommand),
    (Keys.skip in compile) := shouldSkipCompile
  )

  def doCommand(configs: Configuration*)(state: State, args: Seq[String]): State = {
    shouldSkipCompile = true // start skipping compiles

    ... // do stuff that would normally trigger a compile such as running the packageBin task

    shouldSkipCompile = false // stop skipping compiles
  }
}
很好,你当然可以接受

object SbtQuickInstallPlugin extends Plugin {
  private lazy val installCommand =  Command.args("quick-install", "quick install that skips compile step")(doCommand(Configurations.Compile))

  private var shouldSkipCompile = false  // by default, don't skip compiles

  override lazy val settings = Seq(
    commands ++= Seq(installCommand),
    (Keys.skip in compile) := shouldSkipCompile
  )

  def doCommand(configs: Configuration*)(state: State, args: Seq[String]): State = {
    shouldSkipCompile = true // start skipping compiles

    ... // do stuff that would normally trigger a compile such as running the packageBin task

    shouldSkipCompile = false // stop skipping compiles
  }
}