Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a task when any file in given directory is changed in SBT?

Tags:

sbt

Is there a way to run a task on every code change in a given directory? Preferably, something that works well with ~ operator in SBT so that I could do:

~jadeCompile

to run custom jadeCompile task.

like image 481
Arg Avatar asked Jan 02 '14 09:01

Arg


1 Answers

Take a look at the documentation for triggered execution. You can configure the watched directory using the watchSources setting. This is a bit trickier as only Scala source files will be watched by default, so we need to specify an appropriate path finder:

watchSources <++= baseDirectory map { path => 
    ((path / "src/main/jade") ** "*.jade").get }

The watchSources setting is not scoped, so you will need to watch all sources at once. Then you just have to run:

~jadeCompile
like image 146
Nicolas Cortot Avatar answered Oct 06 '22 12:10

Nicolas Cortot