aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2016-06-19 22:19:39 -0400
committerChristopher Vogt <oss.nsp@cvogt.org>2016-09-12 16:00:26 +0100
commitede10d4d0e139eb8f831b7241d29fb82d8996e73 (patch)
tree18e63106b4bd537c11f900f89d573cb9b73cb415
parentd7e7265c5509a389f7fbdba77bdc668d6d602a7c (diff)
downloadcbt-ede10d4d0e139eb8f831b7241d29fb82d8996e73.tar.gz
cbt-ede10d4d0e139eb8f831b7241d29fb82d8996e73.tar.bz2
cbt-ede10d4d0e139eb8f831b7241d29fb82d8996e73.zip
better error message for missing build.scala and missing class Build
-rw-r--r--stage2/BuildBuild.scala14
-rw-r--r--test/empty-build-file/Main.scala5
-rw-r--r--test/empty-build-file/build/build.scala0
-rw-r--r--test/no-build-file/Main.scala5
-rw-r--r--test/no-build-file/build/foo.scala0
-rw-r--r--test/test.scala12
6 files changed, 30 insertions, 6 deletions
diff --git a/stage2/BuildBuild.scala b/stage2/BuildBuild.scala
index b6d92c4..b230b01 100644
--- a/stage2/BuildBuild.scala
+++ b/stage2/BuildBuild.scala
@@ -54,15 +54,17 @@ trait BuildBuild extends BaseBuild{
.newInstance(managedContext)
} catch {
case e: ClassNotFoundException if e.getMessage == lib.buildClassName =>
- throw new Exception("You need to remove the directory or define a class Build in: "+context.projectDirectory)
+ throw new Exception("You need to define a class Build in build.scala in: "+context.projectDirectory)
}
}
+ } else if( projectDirectory.listFiles.exists( _.getName.endsWith(".scala") ) ){
+ throw new Exception(
+ "No file build.scala (lower case) found in " ++ projectDirectory.getPath
+ )
+ } else if( projectDirectory.getParentFile.getName == "build" ){
+ new BasicBuild( managedContext ) with BuildBuild
} else {
- if( projectDirectory.getParentFile.getName == "build" ){
- new BasicBuild( managedContext ) with BuildBuild
- } else {
- new BasicBuild( managedContext )
- }
+ new BasicBuild( managedContext )
}
)
try{
diff --git a/test/empty-build-file/Main.scala b/test/empty-build-file/Main.scala
new file mode 100644
index 0000000..19d4beb
--- /dev/null
+++ b/test/empty-build-file/Main.scala
@@ -0,0 +1,5 @@
+object Main{
+ def main( args: Array[String] ): Unit = {
+ println( Console.GREEN ++ "Hello World" ++ Console.RESET )
+ }
+}
diff --git a/test/empty-build-file/build/build.scala b/test/empty-build-file/build/build.scala
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/empty-build-file/build/build.scala
diff --git a/test/no-build-file/Main.scala b/test/no-build-file/Main.scala
new file mode 100644
index 0000000..19d4beb
--- /dev/null
+++ b/test/no-build-file/Main.scala
@@ -0,0 +1,5 @@
+object Main{
+ def main( args: Array[String] ): Unit = {
+ println( Console.GREEN ++ "Hello World" ++ Console.RESET )
+ }
+}
diff --git a/test/no-build-file/build/foo.scala b/test/no-build-file/build/foo.scala
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/no-build-file/build/foo.scala
diff --git a/test/test.scala b/test/test.scala
index 0158ddd..65790f8 100644
--- a/test/test.scala
+++ b/test/test.scala
@@ -202,6 +202,18 @@ object Main{
assert(res.err contains "Build cannot be cast to cbt.BuildInterface", res.err)
}
+ {
+ val res = runCbt("no-build-file", Seq("run"))
+ assert(!res.exit0)
+ assert(res.err contains "No file build.scala (lower case) found in", res.err)
+ }
+
+ {
+ val res = runCbt("empty-build-file", Seq("run"))
+ assert(!res.exit0)
+ assert(res.err contains "You need to define a class Build in build.scala in", res.err)
+ }
+
System.err.println(" DONE!")
System.err.println( successes.toString ++ " succeeded, "++ failures.toString ++ " failed" )
if(failures > 0) System.exit(1) else System.exit(0)