From 47a93993a84c572b4a2cd4562b52ec552f36879a Mon Sep 17 00:00:00 2001 From: Christopher Vogt Date: Tue, 8 Nov 2016 00:58:30 -0500 Subject: Add support for dynamic re-configuration. The exact precedence rule of override code vs original code may still need to be tweaked as we go along. --- stage2/BasicBuild.scala | 4 ++++ stage2/BuildBuild.scala | 17 ++++++++++++++--- stage2/Lib.scala | 14 +++++++++++++- 3 files changed, 31 insertions(+), 4 deletions(-) (limited to 'stage2') diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala index ef4757e..752e0d2 100644 --- a/stage2/BasicBuild.scala +++ b/stage2/BasicBuild.scala @@ -246,6 +246,7 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with Trigge override def show = this.getClass.getSimpleName ++ "(" ++ projectDirectory.string ++ ")" // TODO: allow people not provide the method name, maybe via macro + // TODO: pull this out into lib /** caches given value in context keyed with given key and projectDirectory the context is fresh on every complete run of cbt @@ -261,4 +262,7 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with Trigge value } } + + // a method that can be called only to trigger any side-effects + final def `void` = () } diff --git a/stage2/BuildBuild.scala b/stage2/BuildBuild.scala index 68603da..5eb7622 100644 --- a/stage2/BuildBuild.scala +++ b/stage2/BuildBuild.scala @@ -1,14 +1,18 @@ package cbt import java.nio.file._ -trait BuildBuild extends BaseBuild{ - private final val managedContext = context.copy( +trait BuildBuild extends BuildBuildWithoutEssentials{ + override def dependencies = + super.dependencies :+ plugins.essentials +} +trait BuildBuildWithoutEssentials extends BaseBuild{ + protected final val managedContext = context.copy( projectDirectory = managedBuildDirectory, parentBuild=Some(this) ) object plugins{ - // TODO: maybe move this out of the OO? + // TODO: move this out of the OO final lazy val scalaTest = DirectoryDependency( context.cbtHome ++ "/plugins/scalatest" ) final lazy val sbtLayout = DirectoryDependency( context.cbtHome ++ "/plugins/sbt_layout" ) final lazy val scalaJs = DirectoryDependency( context.cbtHome ++ "/plugins/scalajs" ) @@ -17,6 +21,7 @@ trait BuildBuild extends BaseBuild{ final lazy val wartremover = DirectoryDependency( context.cbtHome ++ "/plugins/wartremover" ) final lazy val uberJar = DirectoryDependency( context.cbtHome ++ "/plugins/uber-jar" ) final lazy val sonatypeRelease = DirectoryDependency( context.cbtHome ++ "/plugins/sonatype-release" ) + final lazy val essentials = DirectoryDependency( context.cbtHome ++ "/plugins/essentials" ) } override def dependencies = @@ -64,6 +69,12 @@ trait BuildBuild extends BaseBuild{ throw new Exception( "No file build.scala (lower case) found in " ++ projectDirectory.getPath ) + /* + // is this not needed? + } else if( projectDirectory.getParentFile.getName == "build" && projectDirectory.getParentFile.getParentFile.getName == "build" ){ + // can't use essentiasy, when building essentials themselves + new BasicBuild( managedContext ) with BuildBuildWithoutEssentials + */ } else if( projectDirectory.getParentFile.getName == "build" ){ new BasicBuild( managedContext ) with BuildBuild } else { diff --git a/stage2/Lib.scala b/stage2/Lib.scala index 25183a3..3f6242f 100644 --- a/stage2/Lib.scala +++ b/stage2/Lib.scala @@ -48,7 +48,19 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ val rootBuildClassName = if( useBasicBuildBuild ) buildBuildClassName else buildClassName try{ - if(useBasicBuildBuild) default( context ) else new cbt.BasicBuild( context.copy( projectDirectory = start ) ) with BuildBuild + if(useBasicBuildBuild) + default( context ) + 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 + context.projectDirectory == (context.cbtHome ++ "/plugins/essentials") + || context.projectDirectory == (context.cbtHome ++ "/libraries/eval") + || context.projectDirectory == (context.cbtHome ++ "/plugins/scalatest") + ) + new cbt.BasicBuild( context.copy( projectDirectory = start ) ) with BuildBuildWithoutEssentials + 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) -- cgit v1.2.3