sbt - 如何复制任务,例如编译?

标签 sbt

由于各种原因,我有一个由 compile 触发的任务 enhance 因为我们需要它来运行我们的代码,并且我不希望程序员只是编译而忘记增强。

这工作正常,但在某些情况下,特别是调试增强器时,我需要一个 compileOnly 任务,它与 compile 执行完全相同的操作,但没有附加触发器。

有没有办法“克隆”编译?我尝试过:

object EnhancerBuild extends Build {
  lazy val compileOnly = taskKey[Analysis]("compileOnly") in Compile

  lazy val root = Project("root", file(".")) settings(  
      compileOnly <<= compileTask
   )
}

但它找不到 compilerReportercompileInputs 设置。

最佳答案

除非我弄错了,否则你确实需要另一项任务来模仿 sbt 中的许多任务之一,例如编译。如果是这样,请参阅 build.sbt 中的以下内容:

lazy val compileOnly = taskKey[sbt.inc.Analysis]("compileOnly")

compileOnly <<= (compile in Compile)

根据定义,compileOnly 依赖于 Compile 范围内的 compile

> inspect compileOnly
[info] Task: sbt.inc.Analysis
[info] Description:
[info]  compileOnly
[info] Provided by:
[info]  {file:/C:/dev/sandbox/compile-copy/}compile-copy/*:compileOnly
[info] Defined at:
[info]  C:\dev\sandbox\compile-copy\build.sbt:3
[info] Dependencies:
[info]  compile:compile
[info] Delegates:
[info]  *:compileOnly
[info]  {.}/*:compileOnly
[info]  */*:compileOnly

关于sbt - 如何复制任务,例如编译?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24165571/

相关文章:

git - 如何从我的 sbt 自动增加版本号并上传到 git

scala - 如何在没有 Play 的情况下使用 Play 框架中的 REST 客户端

sbt - 我可以将 sbt 的 `apiMappings` 设置用于托管依赖项吗?

sbt - 如何一起使用 sbt-assembly 和 sbt-aws-plugin? (jarFile 设置 vs 任务冲突)

scala - 为什么IDEA在新建的sbt项目中会报build.sbt错误?

sbt - 如何在项目的 Scala 构建定义中定义包之后的目录结构?

sbt - 如何在不使用聚合的情况下执行对子项目调用 clean 的任务?

scala - 为 Play 项目并行运行 Selenium 测试

scala - SBT:如何定义包含特定路径中所有文件的 includeFilter?

sbt - 仅在安装启动器后立即离线运行 sbt?