本文介绍了sbt 可以执行“编译测试:编译它:编译"吗?作为单个命令,说“*:编译"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常运行 compile test:compile it:compile 并且...希望将击键次数减少到类似 *:compile 的程度.不过,它似乎不起作用.

I'm running compile test:compile it:compile quite often and...would like to cut the number of keystrokes to something like *:compile. It doesn't seem to work, though.

$ sbt *:compile
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Loading project definition from /Users/jacek/oss/scalania/project
[info] Set current project to scalania (in build file:/Users/jacek/oss/scalania/)
[error] No such setting/task
[error] *:compile
[error]          ^

有可能吗?我使用 SBT 0.13.

Is it possible at all? I use SBT 0.13.

推荐答案

test:compile 意味着 compile 所以 compile 不需要在 test:compile 之前显式运行.如果你的 IntegrationTest 配置 extends Testit:compile 意味着 test:compile.

test:compile implies a compile so compile doesn't need to be explicitly run before test:compile. If your IntegrationTest configuration extends Test, it:compile implies test:compile.

一种选择是定义一个执行多个命令的别名:

One option is to define an alias that executes multiple commands:

sbt> alias compileAll = ; test:compile ; it:compile

查看help aliashelp ; 了解详情.您可以通过以下方式将其作为构建的一部分:

See help alias and help ; for details. You can make this a part of your build with:

addCommandAlias("compileAll", "; test:compile ; it:compile")

另一个选项是定义一个依赖于其他人的自定义任务并调用它:

The other option is to define a custom task that depends on the others and call that:

lazy val compileAll = taskKey[Unit]("Compiles sources in all configurations.")

compileAll := { 
   val a = (compile in Test).value
   val b = (compile in IntegrationTest).value
   ()
}

这篇关于sbt 可以执行“编译测试:编译它:编译"吗?作为单个命令,说“*:编译"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 13:29