In SBT, you can use the "~" mark to trigger actions whenever a source file changes. For example,
sbt> ~test
will run the unit tests whenever source changes.
Is there any good way to trigger actions whenever source changes or a local dependency changes? This would be useful when developing two projects simultaneously, where one depends on the other.
I know you can get this behavior by manually specifying a path to a file or the base project, but that's brittle, and SBT already knows where it's getting its local artifacts, so it's something I'd like to avoid.
From the documentation for Triggered Execution, the watchSources
task is where you can add additional files to be watched.
From another question, the managedClasspath
task provides the part of the classpath that comes from managed dependencies.
Then, the following definition adds the managed test classpath to the files to watch for triggered execution:
watchSources <++=
(managedClasspath in Test) map { cp => cp.files }
Define this in each project that you want to trigger on.
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