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.
sbt maps each test class to a task. sbt runs tasks in parallel and within the same JVM by default.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With