diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-19 21:38:02 -0400 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-19 21:38:02 -0400 |
commit | 8f055d10fb3b5494115ffd8bf46b972d0937e234 (patch) | |
tree | e0519bd38f618eaa91303076007383a8f3639484 /plugins | |
parent | ff4bc8f6d8077dd8d96064267c31bdace93d892b (diff) | |
download | cbt-8f055d10fb3b5494115ffd8bf46b972d0937e234.tar.gz cbt-8f055d10fb3b5494115ffd8bf46b972d0937e234.tar.bz2 cbt-8f055d10fb3b5494115ffd8bf46b972d0937e234.zip |
Get rid of the hacky "essential" plugins separation
Let’s keep move them back into stage2 again instead for reduction
of complexity, cbt build speed and convenience of fewer manual
dependencies.
And for that let cbt just include eval from the start.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/essentials/CommandLineOverrides.scala | 27 | ||||
-rw-r--r-- | plugins/essentials/DynamicOverrides.scala | 82 | ||||
-rw-r--r-- | plugins/essentials/MultipleScalaVersions.scala | 9 | ||||
-rw-r--r-- | plugins/essentials/Readme.md | 3 | ||||
-rw-r--r-- | plugins/essentials/SnapshotVersion.scala | 7 | ||||
-rw-r--r-- | plugins/essentials/build/build.scala | 10 |
6 files changed, 0 insertions, 138 deletions
diff --git a/plugins/essentials/CommandLineOverrides.scala b/plugins/essentials/CommandLineOverrides.scala deleted file mode 100644 index 3ffaf21..0000000 --- a/plugins/essentials/CommandLineOverrides.scala +++ /dev/null @@ -1,27 +0,0 @@ -package cbt -trait CommandLineOverrides extends DynamicOverrides{ - def `with`: Any = { - lib.callReflective( - newBuild[DynamicOverrides]( - context.copy( - args = context.args.drop(2) - ) - )( s""" - ${context.args.lift(0).getOrElse("")} - """ ), - context.args.lift(1) orElse Some("void"), - context - ) - } - def eval = { - lib.callReflective( - newBuild[CommandLineOverrides]( - context.copy( - args = ( context.args.lift(0).map("println{ "+_+" }") ).toSeq - ) - ){""}, - Some("with"), - context - ) - } -} diff --git a/plugins/essentials/DynamicOverrides.scala b/plugins/essentials/DynamicOverrides.scala deleted file mode 100644 index 8d67be7..0000000 --- a/plugins/essentials/DynamicOverrides.scala +++ /dev/null @@ -1,82 +0,0 @@ -package cbt -import cbt.eval.Eval -trait DynamicOverrides extends BaseBuild{ - private val twitterEval = { - taskCache[DynamicOverrides]( "eval" ).memoize{ - new Eval{ - override lazy val impliedClassPath: List[String] = context.parentBuild.get.classpath.strings.toList//new ScalaCompilerDependency( context.cbtLastModified, context.paths.mavenCache, scalaVersion ).classpath.strings.toList - override def classLoader = DynamicOverrides.this.getClass.getClassLoader - } - } - } - - protected [cbt] def overrides: String = "" - - // TODO: add support for Build inner classes - import scala.reflect.runtime.universe._ - def newBuild[T <: DynamicOverrides:TypeTag]: T = newBuild[T](context)("") - def newBuild[T <: DynamicOverrides:TypeTag](body: String): T = newBuild[T](context)(body) - def newBuild[T <: DynamicOverrides:TypeTag](context: Context)(body: String): T = { - val tag = typeTag[T] - val mixinClass = tag.mirror.runtimeClass(tag.tpe) - assert(mixinClass.getTypeParameters.size == 0) - val mixin = if( - mixinClass == classOf[Nothing] - || mixinClass.getSimpleName == "Build" - ) "" else " with "+mixinClass.getName - import scala.collection.JavaConverters._ - val parent = Option( - if(this.getClass.getName.startsWith("Evaluator__")) - this.getClass.getName.dropWhile(_ != '$').drop(1).stripSuffix("$1") - else - this.getClass.getName - ).getOrElse( - throw new Exception( "You cannot have more than one newBuild call on the Stack right now." ) - ) - val overrides = "" // currently disables, but can be used to force overrides everywhere - if(mixin == "" && overrides == "" && body == ""){ - // TODO: is it possible for the contructor to have the wrong signature and - // thereby produce a pretty hard to understand error message here? - this.getClass - .getConstructor(classOf[Context]) - .newInstance(context) - .asInstanceOf[T] - } else { - val baseName = "DynamicBuild" + System.currentTimeMillis - val overrideName = baseName+"Overrides" - val (finalName, code) = if(overrides == ""){ - ( - baseName, - s""" - class $baseName(context: _root_.cbt.Context) - extends $parent(context)$mixin{ - $body - } - """ - ) - } else { - ( - overrideName, - s""" - class $baseName(context: _root_.cbt.Context) - extends $parent(context)$mixin{ - $body - } - class $overrideName(context: _root_.cbt.Context) - extends $baseName(context){ - $overrides - } - """ - ) - } - logger.dynamic("Dynamically generated code:\n" ++ code) - twitterEval.compile(code) - val createBuild = twitterEval.apply[Context => T](s"new $finalName(_: _root_.cbt.Context)",false) - createBuild( context ).asInstanceOf[T] - } - } - - def runFlat: ExitCode = newBuild[DynamicOverrides]{""" - override def flatClassLoader = true - """}.run -} diff --git a/plugins/essentials/MultipleScalaVersions.scala b/plugins/essentials/MultipleScalaVersions.scala deleted file mode 100644 index 5d896dd..0000000 --- a/plugins/essentials/MultipleScalaVersions.scala +++ /dev/null @@ -1,9 +0,0 @@ -package cbt - -trait MultipleScalaVersions extends DynamicOverrides{ - def scalaVersions: Seq[String] = Seq(scalaVersion, "2.10.6") - def cross: Seq[MultipleScalaVersions] = - scalaVersions.map{ v => - newBuild[MultipleScalaVersions](context.copy(scalaVersion = Some(v)))("") - } -} diff --git a/plugins/essentials/Readme.md b/plugins/essentials/Readme.md deleted file mode 100644 index 76d3756..0000000 --- a/plugins/essentials/Readme.md +++ /dev/null @@ -1,3 +0,0 @@ -Essential CBT plugins - -Not part of CBT's core to keep it slim and so they can have dependencies if needed. diff --git a/plugins/essentials/SnapshotVersion.scala b/plugins/essentials/SnapshotVersion.scala deleted file mode 100644 index 1f7eb23..0000000 --- a/plugins/essentials/SnapshotVersion.scala +++ /dev/null @@ -1,7 +0,0 @@ -package cbt - -trait SnapshotVersion extends ArtifactInfo with DynamicOverrides{ - def snapshot = newBuild[SnapshotVersion]{""" - override def version = super.version ++ "-SNAPSHOT" - """} -} diff --git a/plugins/essentials/build/build.scala b/plugins/essentials/build/build.scala deleted file mode 100644 index 450130a..0000000 --- a/plugins/essentials/build/build.scala +++ /dev/null @@ -1,10 +0,0 @@ -import cbt._ -// TODO: maybe move this back into stage2 to avoid having to call zinc separately for this as a plugin -// and to avoid the special casing "BuildBuildWithoutEssentials" -class Build(val context: Context) extends BaseBuild{ - override def dependencies = ( - super.dependencies - :+ context.cbtDependency - :+ libraries.eval - ) -} |