aboutsummaryrefslogtreecommitdiff
path: root/stage1
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2017-03-12 22:00:00 -0400
committerChristopher Vogt <oss.nsp@cvogt.org>2017-03-12 22:34:02 -0400
commit828adac48d0e08766d192c7ce01021083cfc4d67 (patch)
tree06e19c3f9117c24e6c6a5e8a95990011a0efe4b3 /stage1
parentc14e288996d2b56b6b06a0624f4f2fca315369c7 (diff)
downloadcbt-828adac48d0e08766d192c7ce01021083cfc4d67.tar.gz
cbt-828adac48d0e08766d192c7ce01021083cfc4d67.tar.bz2
cbt-828adac48d0e08766d192c7ce01021083cfc4d67.zip
fix file watching for real
last file watching update didn’t work well enough. This now - rips out barbary watch service as it seems buggy crashing the jvm - make cbt exclusively write files to watch to a file - uses fswatch instead watching all files in that file
Diffstat (limited to 'stage1')
-rw-r--r--stage1/ContextImplementation.scala2
-rw-r--r--stage1/Stage1.scala22
-rw-r--r--stage1/Stage1Lib.scala8
-rw-r--r--stage1/cbt.scala16
-rw-r--r--stage1/resolver.scala2
5 files changed, 27 insertions, 23 deletions
diff --git a/stage1/ContextImplementation.scala b/stage1/ContextImplementation.scala
index 90d9d5f..6762cb8 100644
--- a/stage1/ContextImplementation.scala
+++ b/stage1/ContextImplementation.scala
@@ -16,7 +16,7 @@ class ContextImplementation(
override val cbtRootHome: File,
override val compatibilityTarget: File,
override val parentBuildOrNull: BuildInterface,
- override val triggerLoopFilesArray: Array[File]
+ override val loop: Boolean
) extends Context{
@deprecated("this method is replaced by workingDirectory","")
def projectDirectory = workingDirectory
diff --git a/stage1/Stage1.scala b/stage1/Stage1.scala
index 48d0ae9..e419e67 100644
--- a/stage1/Stage1.scala
+++ b/stage1/Stage1.scala
@@ -42,7 +42,8 @@ class Stage2Args(
val cache: File,
val cbtHome: File,
val compatibilityTarget: File,
- val stage2sourceFiles: Seq[File]
+ val stage2sourceFiles: Seq[File],
+ val loop: Boolean
)(
implicit val transientCache: java.util.Map[AnyRef,AnyRef], val classLoaderCache: ClassLoaderCache, val logger: Logger
){
@@ -60,7 +61,9 @@ object Stage1{
val (_, cbtLastModified, classLoader) = buildStage2(
buildStage1,
context.cbtHome,
- context.cache
+ context.cache,
+ context.cwd,
+ context.loop
)(context.transientCache, new ClassLoaderCache( context.persistentCache ), logger)
classLoader
@@ -75,7 +78,7 @@ object Stage1{
}
def buildStage2(
- buildStage1: BuildStage1Result, cbtHome: File, cache: File
+ buildStage1: BuildStage1Result, cbtHome: File, cache: File, cwd: File, loop: Boolean
)(
implicit transientCache: java.util.Map[AnyRef,AnyRef], classLoaderCache: ClassLoaderCache, logger: Logger
): (Seq[File], Long, ClassLoader) = {
@@ -99,6 +102,8 @@ object Stage1{
)
logger.stage1("Compiling stage2 if necessary")
+ if(loop)
+ lib.addLoopFiles( cwd, stage2sourceFiles.toSet )
val Some( stage2LastModified ) = compile(
buildStage1.stage1LastModified,
stage2sourceFiles, stage2Target, stage2StatusFile,
@@ -158,6 +163,7 @@ object Stage1{
_args: Array[String],
cache: File,
cbtHome: File,
+ loop: Boolean,
buildStage1: BuildStage1Result,
persistentCache: java.util.Map[AnyRef,AnyRef]
): Int = {
@@ -168,17 +174,19 @@ object Stage1{
implicit val transientCache: java.util.Map[AnyRef,AnyRef] = new java.util.HashMap
implicit val classLoaderCache = new ClassLoaderCache( persistentCache )
- val (stage2sourceFiles, stage2LastModified, classLoader) = buildStage2( buildStage1, cbtHome, cache )
+ val cwd = new File( args.args(0) )
+ val (stage2sourceFiles, stage2LastModified, classLoader) = buildStage2( buildStage1, cbtHome, cache, cwd, loop )
val stage2Args = new Stage2Args(
- new File( args.args(0) ),
- args.args.drop(1).toVector,
+ cwd,
+ args.args.drop(2).toVector,
// launcher changes cause entire nailgun restart, so no need for them here
stage2LastModified = stage2LastModified,
cache,
cbtHome,
new File(buildStage1.compatibilityClasspath),
- stage2sourceFiles
+ stage2sourceFiles,
+ loop
)
logger.stage1(s"Run Stage2")
diff --git a/stage1/Stage1Lib.scala b/stage1/Stage1Lib.scala
index d99354c..1cda9fd 100644
--- a/stage1/Stage1Lib.scala
+++ b/stage1/Stage1Lib.scala
@@ -204,7 +204,6 @@ class Stage1Lib( logger: Logger ) extends BaseLib{
}
}
-
def compile(
cbtLastModified: Long,
sourceFiles: Seq[File],
@@ -475,6 +474,13 @@ ${sourceFiles.sorted.mkString(" \\\n")}
cache.get( cp, lastModified )
}
+ def addLoopFiles(cwd: File, files: Set[File]) = {
+ lib.write(
+ cwd / "target/.cbt-loop.tmp",
+ files.map(_ + "\n").mkString,
+ StandardOpenOption.APPEND
+ )
+ }
}
import scala.reflect._
diff --git a/stage1/cbt.scala b/stage1/cbt.scala
index 05737d0..cb6cb10 100644
--- a/stage1/cbt.scala
+++ b/stage1/cbt.scala
@@ -84,13 +84,6 @@ object `package`{
}
}
}
- implicit class BuildInterfaceExtensions(build: BuildInterface){
- import build._
- // TODO: if every build has a method triggers a callback if files change
- // then we wouldn't need this and could provide this method from a
- // plugin rather than hard-coding trigger files stuff in cbt
- def triggerLoopFiles: Set[File] = triggerLoopFilesArray.to
- }
implicit class ArtifactInfoExtensions(subject: ArtifactInfo){
import subject._
def str = s"$groupId:$artifactId:$version"
@@ -121,9 +114,6 @@ object `package`{
def scalaVersion = Option(scalaVersionOrNull)
def parentBuild = Option(parentBuildOrNull)
def cbtLastModified: scala.Long = subject.cbtLastModified
- def triggerLoopFiles: Set[File] = triggerLoopFilesArray.toSet[File]
-
- private[cbt] def loopFile = cwd / "target/.cbt-loop.tmp"
def copy(
workingDirectory: File = workingDirectory,
@@ -133,7 +123,9 @@ object `package`{
scalaVersion: Option[String] = scalaVersion,
cbtHome: File = cbtHome,
parentBuild: Option[BuildInterface] = None,
- triggerLoopFiles: Set[File] = Set()
+ transientCache: java.util.Map[AnyRef,AnyRef] = transientCache,
+ persistentCache: java.util.Map[AnyRef,AnyRef] = persistentCache,
+ loop: Boolean = loop
): Context = new ContextImplementation(
workingDirectory,
cwd,
@@ -149,7 +141,7 @@ object `package`{
cbtRootHome,
compatibilityTarget,
parentBuild.getOrElse(null),
- (triggerLoopFiles ++ triggerLoopFilesArray.toSet[File]).toArray
+ loop
)
}
}
diff --git a/stage1/resolver.scala b/stage1/resolver.scala
index 1304f76..b40fb7b 100644
--- a/stage1/resolver.scala
+++ b/stage1/resolver.scala
@@ -29,7 +29,6 @@ trait DependencyImplementation extends Dependency{
@deprecated("this method was replaced by dependenciesArray","")
def dependencyClasspathArray = dependencyClasspath.files.toArray
-
/*
//private type BuildCache = KeyLockedLazyCache[Dependency, Future[ClassPath]]
def exportClasspathConcurrently: ClassPath = {
@@ -195,7 +194,6 @@ case class CbtDependencies(mavenCache: File, nailgunTarget: File, stage1Target:
stage2Target,
stage1Dependency +:
MavenResolver(cbtLastModified, mavenCache,mavenCentral).bind(
- MavenDependency("net.incongru.watchservice","barbary-watchservice","1.0"),
MavenDependency("org.eclipse.jgit", "org.eclipse.jgit", "4.2.0.201601211800-r")
)
)