diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2016-03-09 00:22:10 -0500 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2016-03-09 00:22:10 -0500 |
commit | a5a8515c22a7b434a0da34de48caafbef7e5ee8e (patch) | |
tree | 7bfa44c5e9cf3248ee60f3c929edf3d49f4b3e5f /stage2/Lib.scala | |
parent | 19fa46346c440c00b9f4a6509784928232c136e2 (diff) | |
download | cbt-a5a8515c22a7b434a0da34de48caafbef7e5ee8e.tar.gz cbt-a5a8515c22a7b434a0da34de48caafbef7e5ee8e.tar.bz2 cbt-a5a8515c22a7b434a0da34de48caafbef7e5ee8e.zip |
fix compile looking to only trigger on the provided files, not other files in the same directories
Diffstat (limited to 'stage2/Lib.scala')
-rw-r--r-- | stage2/Lib.scala | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/stage2/Lib.scala b/stage2/Lib.scala index 6bb9c0b..6f83859 100644 --- a/stage2/Lib.scala +++ b/stage2/Lib.scala @@ -148,7 +148,7 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ .filterNot(t => anyRefMembers contains taskName(t)) } - class ReflectBuild(build: Build) extends ReflectObject(build){ + class ReflectBuild(val build: Build) extends ReflectObject(build){ def usage = { val baseTasks = lib.taskNames(ru.typeOf[Build]) val thisTasks = lib.taskNames(subclassType) diff baseTasks @@ -381,10 +381,12 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ import scala.collection.JavaConversions._ val watcher = WatchService.newWatchService - files.map{ - file => - if(file.isFile) dirname(file) - else file + val realFiles = files.map(realpath) + + realFiles.map{ + // WatchService can only watch folders + case file if file.isFile => dirname(file) + case file => file }.distinct.map{ file => val watchableFile = new WatchableFile(file) val key = watchableFile.register( @@ -398,13 +400,19 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ scala.util.control.Breaks.breakable{ while(true){ logger.loop("Waiting for file changes...") + logger.loop("Waiting for file changes...2") Option(watcher.take).map{ key => val changedFiles = key .pollEvents + .toVector .filterNot(_.kind == StandardWatchEventKind.OVERFLOW) .map(_.context.toString) + // make sure we don't react on other files changed + // in the same folder like the files we care about + .filter{ name => realFiles.exists(name startsWith _.toString) } .map(new File(_)) + changedFiles.foreach( f => logger.loop( "Changed: " ++ f.toString ) ) changedFiles.collect(action) key.reset |