diff options
-rw-r--r-- | stage2/Lib.scala | 26 | ||||
-rw-r--r-- | stage2/Stage2.scala | 2 |
2 files changed, 11 insertions, 17 deletions
diff --git a/stage2/Lib.scala b/stage2/Lib.scala index c007906..769cd97 100644 --- a/stage2/Lib.scala +++ b/stage2/Lib.scala @@ -21,19 +21,14 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ val buildClassName = "Build" val buildBuildClassName = "BuildBuild" - /** Loads Build for given Context */ - def loadDynamic(context: Context, default: Context => BuildInterface = new BasicBuild(_)): BuildInterface = { - context.logger.composition( context.logger.showInvocation("Build.loadDynamic",context) ) - loadRoot(context, default).finalBuild - } /** Loads whatever Build needs to be executed first in order to eventually build the build for the given context. This can either the Build itself, of if exists a BuildBuild or a BuildBuild for a BuildBuild and so on. */ - def loadRoot(context: Context, default: Context => BuildInterface = new BasicBuild(_)): BuildInterface = { - def findStartDir(projectDirectory: File): File = { - val buildDir = realpath( projectDirectory ++ "/build" ) - if(buildDir.exists) findStartDir(buildDir) else projectDirectory + def loadRoot(context: Context): BuildInterface = { + def findStartDir(directory: File): File = { + val buildDir = realpath( directory ++ "/build" ) + if(buildDir.exists) findStartDir(buildDir) else directory } val directory = context.projectDirectory @@ -42,13 +37,12 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ val start = findStartDir(directory) - val useBasicBuildBuild = context.projectDirectory == start + val useBasicBuild = directory == start && start.getName != "build" - val rootBuildClassName = if( useBasicBuildBuild ) buildBuildClassName else buildClassName try{ - if(useBasicBuildBuild) - default( context ) - else if( + if(useBasicBuild) { + new BasicBuild( context.copy( projectDirectory = directory) ) + } else if( // essentials depends on eval, which has a build that depends on scalatest // this means in these we can't depend on essentials // hopefully we find a better way that this pretty hacky exclusion rule @@ -60,8 +54,8 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ else new cbt.BasicBuild( context.copy( projectDirectory = start ) ) with BuildBuild } catch { - case e:ClassNotFoundException if e.getMessage == rootBuildClassName => - throw new Exception(s"no class $rootBuildClassName found in " ++ start.string) + case e:ClassNotFoundException if e.getMessage == "Build" => + throw new Exception(s"no class Build found in " ++ start.string) } } diff --git a/stage2/Stage2.scala b/stage2/Stage2.scala index b7b6d33..dfbead3 100644 --- a/stage2/Stage2.scala +++ b/stage2/Stage2.scala @@ -71,7 +71,7 @@ object Stage2 extends Stage2Base{ scala.util.control.Breaks.break case file if triggerFiles.exists(file.toString startsWith _.toString) => - val build = lib.loadDynamic(context) + val build = lib.loadRoot(context).finalBuild logger.loop(s"Re-running $task for " ++ build.show) call(build) } |