aboutsummaryrefslogtreecommitdiff
path: root/stage1
diff options
context:
space:
mode:
Diffstat (limited to 'stage1')
-rw-r--r--stage1/ContextImplementation.scala3
-rw-r--r--stage1/Stage1.scala18
-rw-r--r--stage1/Stage1Lib.scala8
-rw-r--r--stage1/cbt.scala13
4 files changed, 27 insertions, 15 deletions
diff --git a/stage1/ContextImplementation.scala b/stage1/ContextImplementation.scala
index b263ef4..90d9d5f 100644
--- a/stage1/ContextImplementation.scala
+++ b/stage1/ContextImplementation.scala
@@ -15,7 +15,8 @@ class ContextImplementation(
override val cbtHome: File,
override val cbtRootHome: File,
override val compatibilityTarget: File,
- override val parentBuildOrNull: BuildInterface
+ override val parentBuildOrNull: BuildInterface,
+ override val triggerLoopFilesArray: Array[File]
) extends Context{
@deprecated("this method is replaced by workingDirectory","")
def projectDirectory = workingDirectory
diff --git a/stage1/Stage1.scala b/stage1/Stage1.scala
index 714ed65..85ec0e9 100644
--- a/stage1/Stage1.scala
+++ b/stage1/Stage1.scala
@@ -42,7 +42,8 @@ class Stage2Args(
val stage2LastModified: Long,
val cache: File,
val cbtHome: File,
- val compatibilityTarget: File
+ val compatibilityTarget: File,
+ val stage2sourceFiles: Seq[File]
)(
implicit val transientCache: java.util.Map[AnyRef,AnyRef], val classLoaderCache: ClassLoaderCache, val logger: Logger
){
@@ -57,7 +58,7 @@ object Stage1{
def getBuild( _context: java.lang.Object, buildStage1: BuildStage1Result ) = {
val context = _context.asInstanceOf[Context]
val logger = new Logger( context.enabledLoggers, buildStage1.start )
- val (cbtLastModified, classLoader) = buildStage2(
+ val (_, cbtLastModified, classLoader) = buildStage2(
buildStage1,
context.cbtHome,
context.cache
@@ -76,7 +77,9 @@ object Stage1{
def buildStage2(
buildStage1: BuildStage1Result, cbtHome: File, cache: File
- )(implicit transientCache: java.util.Map[AnyRef,AnyRef], classLoaderCache: ClassLoaderCache, logger: Logger): (Long, ClassLoader) = {
+ )(
+ implicit transientCache: java.util.Map[AnyRef,AnyRef], classLoaderCache: ClassLoaderCache, logger: Logger
+ ): (Seq[File], Long, ClassLoader) = {
import buildStage1._
@@ -149,7 +152,7 @@ object Stage1{
)
}
- ( stage2LastModified, stage2ClassLoader )
+ ( stage2sourceFiles, stage2LastModified, stage2ClassLoader )
}
def run(
@@ -166,7 +169,7 @@ object Stage1{
implicit val transientCache: java.util.Map[AnyRef,AnyRef] = new java.util.HashMap
implicit val classLoaderCache = new ClassLoaderCache( persistentCache )
- val (stage2LastModified, classLoader) = buildStage2( buildStage1, cbtHome, cache )
+ val (stage2sourceFiles, stage2LastModified, classLoader) = buildStage2( buildStage1, cbtHome, cache )
val stage2Args = new Stage2Args(
new File( args.args(0) ),
@@ -175,7 +178,8 @@ object Stage1{
stage2LastModified = stage2LastModified,
cache,
cbtHome,
- new File(buildStage1.compatibilityClasspath)
+ new File(buildStage1.compatibilityClasspath),
+ stage2sourceFiles
)
logger.stage1(s"Run Stage2")
@@ -193,7 +197,7 @@ object Stage1{
case _ => ExitCode.Success
}
).integer
- logger.stage1(s"Stage1 end")
+ logger.stage1(s"Stage1 end with exit code " + exitCode)
return exitCode;
}
}
diff --git a/stage1/Stage1Lib.scala b/stage1/Stage1Lib.scala
index 01115d4..f701c72 100644
--- a/stage1/Stage1Lib.scala
+++ b/stage1/Stage1Lib.scala
@@ -349,20 +349,22 @@ ${sourceFiles.sorted.mkString(" \\\n")}
res
}
- def trapExitCode( code: => ExitCode ): ExitCode = {
+ def trapExitCodeOrValue[T]( result: => T ): Either[ExitCode,T] = {
val trapExitCodeBefore = TrapSecurityManager.trapExitCode().get
try{
TrapSecurityManager.trapExitCode().set(true)
- code
+ Right( result )
} catch {
case CatchTrappedExitCode(exitCode) =>
logger.stage1(s"caught exit code $exitCode")
- exitCode
+ Left( exitCode )
} finally {
TrapSecurityManager.trapExitCode().set(trapExitCodeBefore)
}
}
+ def trapExitCode( code: => ExitCode ): ExitCode = trapExitCodeOrValue(code).merge
+
def ScalaDependency(
groupId: String, artifactId: String, version: String, classifier: Classifier = Classifier.none,
scalaMajorVersion: String, verifyHash: Boolean = true
diff --git a/stage1/cbt.scala b/stage1/cbt.scala
index 062e11d..05737d0 100644
--- a/stage1/cbt.scala
+++ b/stage1/cbt.scala
@@ -87,9 +87,9 @@ 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
+ // 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: Seq[File] = triggerLoopFilesArray.to
+ def triggerLoopFiles: Set[File] = triggerLoopFilesArray.to
}
implicit class ArtifactInfoExtensions(subject: ArtifactInfo){
import subject._
@@ -121,6 +121,9 @@ 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,
@@ -129,7 +132,8 @@ object `package`{
cbtLastModified: Long = cbtLastModified,
scalaVersion: Option[String] = scalaVersion,
cbtHome: File = cbtHome,
- parentBuild: Option[BuildInterface] = None
+ parentBuild: Option[BuildInterface] = None,
+ triggerLoopFiles: Set[File] = Set()
): Context = new ContextImplementation(
workingDirectory,
cwd,
@@ -144,7 +148,8 @@ object `package`{
cbtHome,
cbtRootHome,
compatibilityTarget,
- parentBuild.getOrElse(null)
+ parentBuild.getOrElse(null),
+ (triggerLoopFiles ++ triggerLoopFilesArray.toSet[File]).toArray
)
}
}