aboutsummaryrefslogtreecommitdiff
path: root/stage2/BasicBuild.scala
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2017-02-09 21:20:11 -0500
committerChristopher Vogt <oss.nsp@cvogt.org>2017-02-09 22:43:00 -0500
commite8673866b79f7473391dcee26243eee80d5d3cb6 (patch)
tree16146affeebdb58cd302a1f8527220c906818c96 /stage2/BasicBuild.scala
parentbee13ba7a4458482ce00a5c6bae4cd64328c4e5e (diff)
downloadcbt-e8673866b79f7473391dcee26243eee80d5d3cb6.tar.gz
cbt-e8673866b79f7473391dcee26243eee80d5d3cb6.tar.bz2
cbt-e8673866b79f7473391dcee26243eee80d5d3cb6.zip
idempotent change propagation
using lastModified instead of a non-idempotent needsUpdate flag this fixes a bug where dependees would not be rebuilt if cbt exited or was killed after dependencies were already rebuilt.
Diffstat (limited to 'stage2/BasicBuild.scala')
-rw-r--r--stage2/BasicBuild.scala21
1 files changed, 9 insertions, 12 deletions
diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala
index 2fd34c7..ef5411a 100644
--- a/stage2/BasicBuild.scala
+++ b/stage2/BasicBuild.scala
@@ -98,7 +98,7 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with Trigge
}
logEmptySourceDirectories()
- def Resolver( urls: URL* ) = MavenResolver( context.cbtHasChanged, context.paths.mavenCache, urls: _* )
+ def Resolver( urls: URL* ) = MavenResolver( context.cbtLastModified, context.paths.mavenCache, urls: _* )
def ScalaDependency(
groupId: String, artifactId: String, version: String, classifier: Classifier = Classifier.none,
@@ -126,7 +126,7 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with Trigge
val resourcesDirectory = projectDirectory ++ "/resources"
ClassPath( if(resourcesDirectory.exists) Seq(resourcesDirectory) else Nil )
}
- def exportedClasspath : ClassPath = ClassPath(compile.toSeq) ++ resourceClasspath
+ def exportedClasspath : ClassPath = ClassPath(compileFile.toSeq) ++ resourceClasspath
def targetClasspath = ClassPath(Seq(compileTarget))
// ========== compile, run, test ==========
@@ -137,23 +137,20 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with Trigge
"-unchecked"
)
- def needsUpdate: Boolean = taskCache[BaseBuild]("needsUpdate").memoize[java.lang.Boolean](
- context.cbtHasChanged
- || lib.needsUpdate( sourceFiles, compileStatusFile )
- || transitiveDependencies.filterNot(_ == context.parentBuild).exists(_.needsUpdate)
- )
+ final def lastModified: Long = compile.getOrElse(0L)
+
+ final def compileFile: Option[File] = compile.map(_ => compileTarget)
- def compile: Option[File] = taskCache[BaseBuild]("compile").memoize{
+ def compile: Option[Long] = taskCache[BaseBuild]("_compile").memoize{
lib.compile(
- context.cbtHasChanged,
- needsUpdate || context.parentBuild.map(_.needsUpdate).getOrElse(false),
+ context.cbtLastModified,
sourceFiles, compileTarget, compileStatusFile, compileDependencies,
context.paths.mavenCache, scalacOptions, context.classLoaderCache,
zincVersion = zincVersion, scalaVersion = scalaVersion
)
}
- def mainClasses: Seq[Class[_]] = compile.toSeq.flatMap( lib.mainClasses( _, classLoader(classLoaderCache) ) )
+ def mainClasses: Seq[Class[_]] = compileFile.toSeq.flatMap( lib.mainClasses( _, classLoader(classLoaderCache) ) )
def runClass: Option[String] = lib.runClass( mainClasses ).map( _.getName )
@@ -181,7 +178,7 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with Trigge
System.setProperty(colorized, "true")
}
- val scalac = new ScalaCompilerDependency(context.cbtHasChanged, context.paths.mavenCache, scalaVersion)
+ val scalac = new ScalaCompilerDependency(context.cbtLastModified, context.paths.mavenCache, scalaVersion)
lib.runMain(
"scala.tools.nsc.MainGenericRunner",
Seq(