Reload sbt when version changes without requiring full reload

This commit is contained in:
Mark Harrah 2010-01-26 18:39:23 -05:00
parent 31609f57e6
commit 1c6201d3cc
2 changed files with 35 additions and 17 deletions

View File

@ -6,17 +6,6 @@ package sbt
import java.io.File
import scala.collection.immutable.TreeSet
private case class Exit(code: Int) extends xsbti.Exit
{
require(code >= 0)
}
private case class Reboot(val scalaVersion: String, argsList: List[String], configuration: xsbti.AppConfiguration) extends xsbti.Reboot
{
def app = configuration.provider.id
def arguments = argsList.toArray
def baseDirectory = configuration.baseDirectory
}
/** This class is the entry point for sbt. If it is given any arguments, it interprets them
* as actions, executes the corresponding actions, and exits. If there were no arguments provided,
* sbt enters interactive mode.*/
@ -152,7 +141,9 @@ class xMain extends xsbti.AppMain
{
case "" :: tail => continue(project, tail, failAction)
case (ExitCommand | QuitCommand) :: _ => result( Exit(NormalExitCode) )
case RebootCommand :: tail => throw new xsbti.FullReload(rememberCurrent(tail).toArray)
case RebootCommand :: tail =>
val newID = new ApplicationID(configuration.provider.id, baseProject.sbtVersion.value)
result( new Reboot(project.defScalaVersion.value, rememberCurrent(tail), newID, configuration.baseDirectory) )
case InteractiveCommand :: _ => continue(project, prompt(baseProject, project) :: arguments, interactiveContinue)
case SpecificBuild(version, action) :: tail =>
if(Some(version) != baseProject.info.buildScalaVersion)
@ -704,8 +695,4 @@ class xMain extends xsbti.AppMain
private def setProjectError(log: Logger) = logError(log)("Invalid arguments for 'project': expected project name.")
private def logError(log: Logger)(s: String) = { log.error(s); false }
private final class ReloadException(val remainingArguments: List[String], val buildScalaVersion: Option[String]) extends RuntimeException
{
override def fillInStackTrace = this
}
}
}

View File

@ -0,0 +1,31 @@
/* sbt -- Simple Build Tool
* Copyright 2009, 2010 Mark Harrah
*/
package sbt
import java.io.File
private case class Exit(code: Int) extends xsbti.Exit
{
require(code >= 0)
}
private class Reboot(val scalaVersion: String, argsList: List[String], val app: xsbti.ApplicationID, val baseDirectory: File) extends xsbti.Reboot
{
def arguments = argsList.toArray
}
private class ApplicationID(delegate: xsbti.ApplicationID, newVersion: String) extends xsbti.ApplicationID
{
def groupID = delegate.groupID
def name = delegate.name
def version = newVersion
def mainClass = delegate.mainClass
def mainComponents = delegate.mainComponents
def crossVersioned = delegate.crossVersioned
def classpathExtra = delegate.classpathExtra
}
private final class ReloadException(val remainingArguments: List[String], val buildScalaVersion: Option[String]) extends RuntimeException
{
override def fillInStackTrace = this
}