diff options
author | Jan Christopher Vogt <oss.nsp@cvogt.org> | 2016-09-12 17:47:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-12 17:47:07 +0100 |
commit | af5d391a71a86951b6a2252e9f60eeeb0362192d (patch) | |
tree | 18e63106b4bd537c11f900f89d573cb9b73cb415 | |
parent | 4c889aedae5108cc8d381e9876c1ae956ff078f2 (diff) | |
parent | ede10d4d0e139eb8f831b7241d29fb82d8996e73 (diff) | |
download | cbt-af5d391a71a86951b6a2252e9f60eeeb0362192d.tar.gz cbt-af5d391a71a86951b6a2252e9f60eeeb0362192d.tar.bz2 cbt-af5d391a71a86951b6a2252e9f60eeeb0362192d.zip |
Merge pull request #219 from cvogt/chris3
fixes and better error messages related to build files
-rw-r--r-- | stage2/BuildBuild.scala | 10 | ||||
-rw-r--r-- | stage2/Scaffold.scala | 1 | ||||
-rw-r--r-- | test/empty-build-file/Main.scala | 5 | ||||
-rw-r--r-- | test/empty-build-file/build/build.scala | 0 | ||||
-rw-r--r-- | test/empty-build/Main.scala | 5 | ||||
-rw-r--r-- | test/empty-build/build/build/dummy | 0 | ||||
-rw-r--r-- | test/no-build-file/Main.scala | 5 | ||||
-rw-r--r-- | test/no-build-file/build/foo.scala | 0 | ||||
-rw-r--r-- | test/test.scala | 12 |
9 files changed, 35 insertions, 3 deletions
diff --git a/stage2/BuildBuild.scala b/stage2/BuildBuild.scala index 5392217..b230b01 100644 --- a/stage2/BuildBuild.scala +++ b/stage2/BuildBuild.scala @@ -54,11 +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 { - new BasicBuild(managedContext) + new BasicBuild( managedContext ) } ) try{ diff --git a/stage2/Scaffold.scala b/stage2/Scaffold.scala index 32e474f..f372a37 100644 --- a/stage2/Scaffold.scala +++ b/stage2/Scaffold.scala @@ -45,7 +45,6 @@ class Build(val context: Context) extends BaseBuild{ "com.lihaoyi" %% "ammonite-ops" % "0.5.5" "com.lihaoyi" % "ammonite-ops_2.11" % "0.5.5" ) - ) */ } """ 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/empty-build/Main.scala b/test/empty-build/Main.scala new file mode 100644 index 0000000..19d4beb --- /dev/null +++ b/test/empty-build/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/build/build/dummy b/test/empty-build/build/build/dummy new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/empty-build/build/build/dummy 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) |