向内置 SBT 任务添加新的任务依赖项? [英] Adding new task dependencies to built-in SBT tasks?

查看:35
本文介绍了向内置 SBT 任务添加新的任务依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以覆盖或修改内置 SBT 任务(如编译)以依赖于我自己的 Build.scala 中的自定义任务?覆盖例如直接编译"是不可能的,因为它已经用惰性 val 定义,因此引用 super.compile 会发出编译器错误super 可能不能用于惰性值".

Is it possible to override or modify built-in SBT tasks (like compile) to depend on custom tasks in my own Build.scala? Overriding e.g. "compile" directly is not possible since it has been defined with lazy val and thus referring to super.compile emits a compiler error "super may be not be used on lazy value".

推荐答案

由于在谷歌搜索如何在 SBT 中添加依赖时出现这个问题,目前的答案是 自 0.13.x 起弃用 并在 1.0 中删除,这里是更新的答案,假设 printActioncompile 应该依赖的任务:

Since this question appears when Googling how to add a dependency in SBT, and the current answers are deprecated as of 0.13.x and removed in 1.0, here's the updated answer, assuming that printAction is the task that compile should depend on:

(Compile/compile) := ((Compile/compile) dependsOn printAction).value

这篇关于向内置 SBT 任务添加新的任务依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆