sbt/launch/Boot.scala

49 lines
1.3 KiB
Scala
Raw Normal View History

2009-08-21 14:12:43 +02:00
/* sbt -- Simple Build Tool
2010-02-08 05:45:19 +01:00
* Copyright 2009, 2010 Mark Harrah
2009-08-21 14:12:43 +02:00
*/
package xsbt.boot
import java.io.File
// The entry point to the launcher
object Boot
{
def main(args: Array[String])
{
args match {
case Array("--version") =>
println("sbt launcher version " + Package.getPackage("xsbt.boot").getImplementationVersion)
case _ =>
System.clearProperty("scala.home") // avoid errors from mixing Scala versions in the same JVM
CheckProxy()
run(args)
}
}
// this arrangement is because Scala 2.7.7 does not properly optimize away
// the tail recursion in a catch statement
final def run(args: Array[String]): Unit = runImpl(args) match {
case Some(newArgs) => run(newArgs)
case None => ()
}
private def runImpl(args: Array[String]): Option[Array[String]] =
try
Launch(args.toList) map exit
2009-08-21 14:12:43 +02:00
catch
{
2009-12-11 03:04:51 +01:00
case b: BootException => errorAndExit(b.toString)
case r: xsbti.RetrieveException => errorAndExit("Error: " + r.getMessage)
case r: xsbti.FullReload => Some(r.arguments)
2009-08-21 14:12:43 +02:00
case e =>
e.printStackTrace
2009-12-11 03:04:51 +01:00
errorAndExit(Pre.prefixError(e.toString))
2009-08-21 14:12:43 +02:00
}
private def errorAndExit(msg: String): Nothing =
2009-08-21 14:12:43 +02:00
{
2009-12-11 03:04:51 +01:00
System.out.println(msg)
exit(1)
2009-08-21 14:12:43 +02:00
}
private def exit(code: Int): Nothing =
System.exit(code).asInstanceOf[Nothing]
2009-08-21 14:12:43 +02:00
}