From ef519e0d91202ef88443df9425f28889435179e3 Mon Sep 17 00:00:00 2001 From: Christopher Vogt Date: Sun, 13 Nov 2016 14:50:12 -0500 Subject: fixes interacting with BuildBuilds from the cli and cleans up. Before this when doing `build/$ cbt dependencies` cbt would not show up because cbt would be using a BaseBuild, not a BuildBuild. Not it does. --- stage2/Lib.scala | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'stage2/Lib.scala') 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) } } -- cgit v1.2.3