aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Christopher Vogt <oss.nsp@cvogt.org>2016-11-13 15:06:22 -0500
committerGitHub <noreply@github.com>2016-11-13 15:06:22 -0500
commit54edd75f96fe6a7078e8bb559dcecbe31b50d225 (patch)
tree31891900cba54c30c254b8bece7524d795d8e622
parentde12007cc8907d98f183e65f50f2f9b4700894c3 (diff)
parentdc5ecb94d182774baa888264291eb3799448328c (diff)
downloadcbt-54edd75f96fe6a7078e8bb559dcecbe31b50d225.tar.gz
cbt-54edd75f96fe6a7078e8bb559dcecbe31b50d225.tar.bz2
cbt-54edd75f96fe6a7078e8bb559dcecbe31b50d225.zip
Merge pull request #308 from cvogt/assert-right-build-class
Assert right build class. Fixes #174
-rw-r--r--examples/wartremover-example/build/build.scala2
-rw-r--r--stage1/cbt.scala1
-rw-r--r--stage2/BasicBuild.scala11
-rw-r--r--stage2/BuildBuild.scala5
4 files changed, 17 insertions, 2 deletions
diff --git a/examples/wartremover-example/build/build.scala b/examples/wartremover-example/build/build.scala
index c715f20..7510f91 100644
--- a/examples/wartremover-example/build/build.scala
+++ b/examples/wartremover-example/build/build.scala
@@ -3,7 +3,7 @@ import cbt._
import org.wartremover.warts.{ Null, Var }
import org.wartremover.WartTraverser
-class Build(val context: Context) extends BuildBuild with WartRemover {
+class Build(val context: Context) extends BaseBuild with WartRemover {
override def wartremoverErrors: Seq[WartTraverser] = Seq(Var, Null)
}
diff --git a/stage1/cbt.scala b/stage1/cbt.scala
index bf82556..6aa73f9 100644
--- a/stage1/cbt.scala
+++ b/stage1/cbt.scala
@@ -8,6 +8,7 @@ object `package`{
implicit class TypeInferenceSafeEquals[T](value: T){
/** if you don't manually upcast, this will catch comparing different types */
def ===(other: T) = value == other
+ def =!=(other: T) = value != other // =!= instead of !==, because it has better precedence
}
val mavenCentral = new URL("https://repo1.maven.org/maven2")
diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala
index d8d1b8b..3ce9ed1 100644
--- a/stage2/BasicBuild.scala
+++ b/stage2/BasicBuild.scala
@@ -18,8 +18,17 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with Trigge
def enableConcurrency = false
final def projectDirectory: File = lib.realpath(context.projectDirectory)
assert( projectDirectory.exists, "projectDirectory does not exist: " ++ projectDirectory.string )
+ assert(
+ projectDirectory.getName =!= "build" ||
+ {
+ def transitiveInterfaces(cls: Class[_]): Vector[Class[_]] = cls.getInterfaces.toVector.flatMap(i => i +: transitiveInterfaces(i))
+ transitiveInterfaces(this.getClass).contains(classOf[BuildBuildWithoutEssentials])
+ },
+ "You need to extend BuildBuild in: " + projectDirectory + "/build"
+ )
+
final def usage: String = lib.usage(this.getClass, show)
-
+
final def taskNames: String = lib.taskNames(this.getClass).sorted.mkString("\n")
// ========== meta data ==========
diff --git a/stage2/BuildBuild.scala b/stage2/BuildBuild.scala
index 5eb7622..0736e7e 100644
--- a/stage2/BuildBuild.scala
+++ b/stage2/BuildBuild.scala
@@ -6,6 +6,11 @@ trait BuildBuild extends BuildBuildWithoutEssentials{
super.dependencies :+ plugins.essentials
}
trait BuildBuildWithoutEssentials extends BaseBuild{
+ assert(
+ projectDirectory.getName === "build",
+ "You can't extend BuildBuild in: " + projectDirectory + "/build"
+ )
+
protected final val managedContext = context.copy(
projectDirectory = managedBuildDirectory,
parentBuild=Some(this)