diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2016-11-13 14:50:12 -0500 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2016-11-13 15:30:06 -0500 |
commit | ef519e0d91202ef88443df9425f28889435179e3 (patch) | |
tree | ba4f2fe44f93d49493404c624818df95623c9466 /stage2 | |
parent | 4b7aec94eaf1200f4ac19a755af8b8cf8601f5d6 (diff) | |
download | cbt-ef519e0d91202ef88443df9425f28889435179e3.tar.gz cbt-ef519e0d91202ef88443df9425f28889435179e3.tar.bz2 cbt-ef519e0d91202ef88443df9425f28889435179e3.zip |
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.
Diffstat (limited to 'stage2')
-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) } |