Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SBT: Watch source and test source changes at the same time

Tags:

scala

sbt

We can make SBT watch for changes like sbt ~compile. However if we do sbt ~compile it doesn't watch for changes to the test sources.

I can make it watch the test sources sbt ~test:compile. but I want to watch both at the same time.

I tried sbt ~compile ~test:compile but this only watches the sources. it doesn't watch the test sources.

like image 947
Knows Not Much Avatar asked Jan 28 '18 19:01

Knows Not Much


People also ask

Does sbt run tests in parallel?

sbt maps each test class to a task. sbt runs tasks in parallel and within the same JVM by default.

Does sbt test compile?

One task that you don't need to fork for is compilation. sbt does the necessary steps for these to work correctly, and you don't need to fork to compile. Again, the fork setting can apply to the run , run-main , and test tasks, with run and run-main sharing the same setting ( run ). The target.

What does sbt reload do?

object Reload extends CancelWatch with Product with Serializable. Action that indicates that the watch should pause while the build is reloaded. This is used to automatically reload the project when the build files (e.g. build.

What does sbt clean do?

clean – delete all generated sources, compiled artifacts, intermediate products, and generally all build-produced files. reload – reload the build, to take into account changes to the sbt plugin and its transitive dependencies.


1 Answers

sbt ~test:compile should watch (and compile) both Compile-scope sources (src/main/) and Test-scope sources (src/test/).The latter depends on the former.

like image 119
laughedelic Avatar answered Oct 08 '22 06:10

laughedelic