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 | |
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')
-rw-r--r-- | stage2/Lib.scala | 18 | ||||
-rw-r--r-- | stage2/Stage2.scala | 6 |
2 files changed, 17 insertions, 7 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 diff --git a/stage2/Stage2.scala b/stage2/Stage2.scala index ed63cf1..392e322 100644 --- a/stage2/Stage2.scala +++ b/stage2/Stage2.scala @@ -40,14 +40,16 @@ object Stage2{ logger.loop("Looping change detection over:\n - "++allTriggerFiles.mkString("\n - ")) - lib.watch(allTriggerFiles) { + lib.watch(allTriggerFiles){ case file if triggerCbtFiles.exists(file.toString startsWith _.toString) => logger.loop("Change is in CBT's own source code.") logger.loop("Restarting CBT.") scala.util.control.Breaks.break case file if triggerFiles.exists(file.toString startsWith _.toString) => - new lib.ReflectBuild( lib.loadDynamic(context) ).callNullary(task) + val reflectBuild = new lib.ReflectBuild( lib.loadDynamic(context) ) + logger.loop(s"Re-running $task for " ++ reflectBuild.build.projectDirectory.toString) + reflectBuild.callNullary(task) } } else { new lib.ReflectBuild(build).callNullary(task) |