Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala SBT: Triggering an action when local dependencies change

Tags:

scala

sbt

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.

like image 744
emchristiansen Avatar asked Nov 12 '22 08:11

emchristiansen


1 Answers

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.

like image 105
Mark Harrah Avatar answered Dec 06 '22 12:12

Mark Harrah