package xsbt.boot
import java.io.File
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")
CheckProxy()
initJansi()
run(args)
}
}
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
catch
{
case b: BootException => errorAndExit(b.toString)
case r: xsbti.RetrieveException => errorAndExit("Error: " + r.getMessage)
case r: xsbti.FullReload => Some(r.arguments)
case e =>
e.printStackTrace
errorAndExit(Pre.prefixError(e.toString))
}
private def errorAndExit(msg: String): Nothing =
{
System.out.println(msg)
exit(1)
}
private def exit(code: Int): Nothing =
System.exit(code).asInstanceOf[Nothing]
private def initJansi() {
try {
val c = Class.forName("org.fusesource.jansi.AnsiConsole")
c.getMethod("systemInstall").invoke(null)
if (System.getProperty("sbt.log.format") eq null)
System.setProperty("sbt.log.format", "true")
} catch {
case ignore: ClassNotFoundException =>
case ex => println("Jansi found on class path but initialization failed: " + ex)
}
}
}