aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Christopher Vogt <oss.nsp@cvogt.org>2016-03-09 00:30:13 -0500
committerJan Christopher Vogt <oss.nsp@cvogt.org>2016-03-09 00:30:13 -0500
commit2251bd69446b4e2f05b6fc929c70d5afa4986fe5 (patch)
tree7bfa44c5e9cf3248ee60f3c929edf3d49f4b3e5f
parentf4ffe8c8937ebe2c14fb4456c4108362f5cd2713 (diff)
parenta5a8515c22a7b434a0da34de48caafbef7e5ee8e (diff)
downloadcbt-2251bd69446b4e2f05b6fc929c70d5afa4986fe5.tar.gz
cbt-2251bd69446b4e2f05b6fc929c70d5afa4986fe5.tar.bz2
cbt-2251bd69446b4e2f05b6fc929c70d5afa4986fe5.zip
Merge pull request #70 from cvogt/chris
fixes
-rwxr-xr-xcbt9
-rw-r--r--stage2/Lib.scala18
-rw-r--r--stage2/Stage2.scala6
3 files changed, 22 insertions, 11 deletions
diff --git a/cbt b/cbt
index 603ec23..09f8d96 100755
--- a/cbt
+++ b/cbt
@@ -212,17 +212,18 @@ stage1 () {
log "Checking if nailgun is up yet." $*
$NG cbt.NailgunLauncher cbt.CheckAlive $CP "$CWD" $* >> $nailgun_out 2>> $nailgun_err
alive=$?
- if [ $alive -eq 131 ]; then
- echo "Nailgun call failed. Try 'cbt kill' and check the error log cbt/nailgun_launcher/target/nailgun.stderr.log" 1>&2
- elif [ $alive -eq 33 ]; then
+ if [ $alive -eq 131 ] || [ $alive -eq 33 ]; then
+ # the 33 is not working right now
+ # echo "Nailgun call failed. Try 'cbt kill' and check the error log cbt/nailgun_launcher/target/nailgun.stderr.log" 1>&2
+ #elif [ $alive -eq 33 ]; then
break
else
log "Nope. Sleeping for 0.5 seconds" $*
if [ "$i" -gt "1" ]; then
echo "Waiting for nailgun to start... (For problems try -Dlog=nailgun or check logs in cbt/nailgun_launcher/target/*.log)" 1>&2
fi
- sleep 0.5
fi
+ sleep 0.5
done
log "Running $mainClass via Nailgun." $*
$NG cbt.NailgunLauncher $mainClass $CP "$CWD" $*
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)