aboutsummaryrefslogtreecommitdiff
path: root/stage2/Lib.scala
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2016-11-13 14:50:12 -0500
committerChristopher Vogt <oss.nsp@cvogt.org>2016-11-13 15:30:06 -0500
commitef519e0d91202ef88443df9425f28889435179e3 (patch)
treeba4f2fe44f93d49493404c624818df95623c9466 /stage2/Lib.scala
parent4b7aec94eaf1200f4ac19a755af8b8cf8601f5d6 (diff)
downloadcbt-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/Lib.scala')
-rw-r--r--stage2/Lib.scala26
1 files changed, 10 insertions, 16 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)
}
}