aboutsummaryrefslogtreecommitdiff
path: root/stage2/BasicBuild.scala
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2017-03-12 01:47:57 -0500
committerChristopher Vogt <oss.nsp@cvogt.org>2017-03-12 11:56:25 -0400
commit244f86a9cdf19904169456c234a2752f125dd427 (patch)
tree51e1f79100cc3651dfce66d4a284584d6bef3997 /stage2/BasicBuild.scala
parent4eb753e4d4ef5be7443b99832892bac697b10b50 (diff)
downloadcbt-244f86a9cdf19904169456c234a2752f125dd427.tar.gz
cbt-244f86a9cdf19904169456c234a2752f125dd427.tar.bz2
cbt-244f86a9cdf19904169456c234a2752f125dd427.zip
revamp loop feature
now CBT and builds pass their file names to the current build via the context. The build then simply blocks until any file changes. Then it returns with a special exit code, which the bash script picks up and restarts CBT. Thats works well for looping over project files. It works less well for looping over builds and CBT itself. For this a build has to success once, so that the .cbt-loop.tmp file exists. Then looping works for cbt and builds, but the file list is not updated in case of compile errors, etc. Fixes - https://github.com/cvogt/cbt/issues/406 - https://github.com/cvogt/cbt/issues/405 - https://github.com/cvogt/cbt/issues/202 - https://github.com/cvogt/cbt/issues/50 - https://github.com/cvogt/cbt/issues/22 We should improve for 1.0 in https://github.com/cvogt/cbt/issues/419 to handle looping over build files and cbt itself smarter.
Diffstat (limited to 'stage2/BasicBuild.scala')
-rw-r--r--stage2/BasicBuild.scala20
1 files changed, 19 insertions, 1 deletions
diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala
index 68bda15..bc6f9d9 100644
--- a/stage2/BasicBuild.scala
+++ b/stage2/BasicBuild.scala
@@ -2,6 +2,7 @@ package cbt
import java.io._
import java.net._
+import java.nio.file._
class BasicBuild(final val context: Context) extends BaseBuild
trait BaseBuild extends BuildInterface with DependencyImplementation with TriggerLoop with SbtDependencyDsl{
@@ -124,7 +125,11 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with Trigge
pathToNestedBuild: _*
)
- def triggerLoopFiles: Seq[File] = sources ++ transitiveDependencies.collect{ case b: TriggerLoop => b.triggerLoopFiles }.flatten
+ def triggerLoopFiles: Set[File] = (
+ context.triggerLoopFiles
+ ++ sources
+ ++ transitiveDependencies.collect{ case b: TriggerLoop => b.triggerLoopFiles }.flatten
+ )
def localJars: Seq[File] =
Seq(projectDirectory ++ "/lib")
@@ -318,4 +323,17 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with Trigge
final def crossScalaVersionsArray = Array(scalaVersion)
def publish: Seq[URL] = Seq()
+
+ def loop = {
+ lib.callReflective(this, context.args.headOption, context.copy(args=context.args.drop(1)))
+ val files = triggerLoopFiles
+ lib.watch{ () =>
+ logger.loop("Looping change detection over:\n - "++files.mkString("\n - "))
+ files
+ }()
+ context.loopFile.getParentFile.mkdirs
+ lib.write( context.loopFile, files.mkString("\n"), StandardOpenOption.CREATE )
+
+ ExitCode(253) // signal bash script to restart
+ }
}