Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can sbt execute "compile test:compile it:compile" as a single command, say "*:compile"?

Tags:

sbt

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]          ^

Is it possible at all? I use SBT 0.13.

like image 868
Jacek Laskowski Avatar asked Dec 02 '13 21:12

Jacek Laskowski


People also ask

Does sbt test compile?

We have a build. sbt file that is used for multiple projects. Doing sbt test:compile compiled the tests for every single project and took over 30 minutes.

How do I compile sbt?

sbt shell has a command prompt (with tab completion and history!). To compile again, press up arrow and then enter. To run your program, type run . To leave sbt shell, type exit or use Ctrl+D (Unix) or Ctrl+Z (Windows).


1 Answers

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

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
   ()
}
like image 90
Mark Harrah Avatar answered Sep 17 '22 20:09

Mark Harrah