2010-02-08 05:45:19 +01:00
|
|
|
/* sbt -- Simple Build Tool
|
2011-04-11 06:44:28 +02:00
|
|
|
* Copyright 2008, 2009, 2010, 2011 Mark Harrah
|
2010-02-08 05:45:19 +01:00
|
|
|
*/
|
2009-09-26 08:18:04 +02:00
|
|
|
package xsbt.boot
|
2009-08-21 14:12:43 +02:00
|
|
|
|
2009-10-18 04:40:02 +02:00
|
|
|
import Pre._
|
2010-01-11 01:01:16 +01:00
|
|
|
import BootConfiguration.{CompilerModuleName, LibraryModuleName}
|
2009-10-16 00:10:11 +02:00
|
|
|
import java.io.File
|
2012-02-05 03:10:30 +01:00
|
|
|
import java.net.{URL, URLClassLoader}
|
|
|
|
|
import java.util.concurrent.Callable
|
2010-06-16 02:38:18 +02:00
|
|
|
import scala.collection.immutable.List
|
2012-02-05 03:10:30 +01:00
|
|
|
import scala.annotation.tailrec
|
2009-08-21 14:12:43 +02:00
|
|
|
|
2009-09-26 08:18:04 +02:00
|
|
|
object Launch
|
2009-08-21 14:12:43 +02:00
|
|
|
{
|
2011-10-15 01:52:54 +02:00
|
|
|
def apply(arguments: List[String]): Option[Int] = apply( (new File("")).getAbsoluteFile , arguments )
|
2009-10-02 04:59:02 +02:00
|
|
|
|
2011-10-15 01:52:54 +02:00
|
|
|
def apply(currentDirectory: File, arguments: List[String]): Option[Int] =
|
2009-09-27 20:39:26 +02:00
|
|
|
Configuration.find(arguments, currentDirectory) match { case (configLocation, newArguments) => configured(currentDirectory, configLocation, newArguments) }
|
|
|
|
|
|
2011-10-15 01:52:54 +02:00
|
|
|
def configured(currentDirectory: File, configLocation: URL, arguments: List[String]): Option[Int] =
|
2009-10-02 04:59:02 +02:00
|
|
|
{
|
|
|
|
|
val config = Configuration.parse(configLocation, currentDirectory)
|
|
|
|
|
Find(config, currentDirectory) match { case (resolved, baseDirectory) => parsed(baseDirectory, resolved, arguments) }
|
|
|
|
|
}
|
2011-10-15 01:52:54 +02:00
|
|
|
def parsed(currentDirectory: File, parsed: LaunchConfiguration, arguments: List[String]): Option[Int] =
|
2009-10-15 02:53:15 +02:00
|
|
|
{
|
|
|
|
|
val propertiesFile = parsed.boot.properties
|
|
|
|
|
import parsed.boot.{enableQuick, promptCreate, promptFill}
|
2009-10-18 04:40:02 +02:00
|
|
|
if(isNonEmpty(promptCreate) && !propertiesFile.exists)
|
2009-10-15 02:53:15 +02:00
|
|
|
Initialize.create(propertiesFile, promptCreate, enableQuick, parsed.appProperties)
|
|
|
|
|
else if(promptFill)
|
|
|
|
|
Initialize.fill(propertiesFile, parsed.appProperties)
|
|
|
|
|
initialized(currentDirectory, parsed, arguments)
|
|
|
|
|
}
|
2011-10-15 01:52:54 +02:00
|
|
|
def initialized(currentDirectory: File, parsed: LaunchConfiguration, arguments: List[String]): Option[Int] =
|
2009-10-18 04:40:02 +02:00
|
|
|
{
|
2010-05-14 00:38:55 +02:00
|
|
|
parsed.logging.debug("Parsed configuration: " + parsed)
|
2010-08-12 00:50:44 +02:00
|
|
|
val resolved = ResolveValues(parsed)
|
2010-05-14 00:38:55 +02:00
|
|
|
resolved.logging.debug("Resolved configuration: " + resolved)
|
2009-10-18 04:40:02 +02:00
|
|
|
explicit(currentDirectory, resolved, arguments)
|
|
|
|
|
}
|
2009-10-02 04:59:02 +02:00
|
|
|
|
2011-10-15 01:52:54 +02:00
|
|
|
def explicit(currentDirectory: File, explicit: LaunchConfiguration, arguments: List[String]): Option[Int] =
|
2010-03-20 00:29:57 +01:00
|
|
|
launch( run(Launcher(explicit)) ) (
|
2009-10-18 04:40:02 +02:00
|
|
|
new RunConfiguration(explicit.getScalaVersion, explicit.app.toID, currentDirectory, arguments) )
|
2009-09-27 20:39:26 +02:00
|
|
|
|
2009-10-02 04:59:02 +02:00
|
|
|
def run(launcher: xsbti.Launcher)(config: RunConfiguration): xsbti.MainResult =
|
2009-08-21 14:12:43 +02:00
|
|
|
{
|
2009-09-27 20:39:26 +02:00
|
|
|
import config._
|
2012-02-05 03:10:30 +01:00
|
|
|
val appProvider: xsbti.AppProvider = launcher.app(app, orNull(scalaVersion)) // takes ~40 ms when no update is required
|
2009-10-18 04:40:02 +02:00
|
|
|
val appConfig: xsbti.AppConfiguration = new AppConfiguration(toArray(arguments), workingDirectory, appProvider)
|
|
|
|
|
|
|
|
|
|
val main = appProvider.newMain()
|
2011-03-01 15:44:45 +01:00
|
|
|
try { main.run(appConfig) }
|
|
|
|
|
catch { case e: xsbti.FullReload => if(e.clean) delete(launcher.bootDirectory); throw e }
|
|
|
|
|
}
|
|
|
|
|
private[this] def delete(f: File)
|
|
|
|
|
{
|
|
|
|
|
if(f.isDirectory)
|
|
|
|
|
{
|
|
|
|
|
val fs = f.listFiles()
|
|
|
|
|
if(fs ne null) fs foreach delete
|
|
|
|
|
}
|
|
|
|
|
if(f.exists) f.delete()
|
2009-09-27 20:39:26 +02:00
|
|
|
}
|
2011-10-15 01:52:54 +02:00
|
|
|
final def launch(run: RunConfiguration => xsbti.MainResult)(config: RunConfiguration): Option[Int] =
|
2009-09-27 20:39:26 +02:00
|
|
|
{
|
|
|
|
|
run(config) match
|
2009-08-21 14:12:43 +02:00
|
|
|
{
|
2011-10-15 01:52:54 +02:00
|
|
|
case e: xsbti.Exit => Some(e.code)
|
|
|
|
|
case c: xsbti.Continue => None
|
2012-02-05 03:10:30 +01:00
|
|
|
case r: xsbti.Reboot => launch(run)(new RunConfiguration(Option(r.scalaVersion), r.app, r.baseDirectory, r.arguments.toList))
|
2009-09-26 08:18:04 +02:00
|
|
|
case x => throw new BootException("Invalid main result: " + x + (if(x eq null) "" else " (class: " + x.getClass + ")"))
|
2009-08-21 14:12:43 +02:00
|
|
|
}
|
2009-08-24 04:21:15 +02:00
|
|
|
}
|
2009-09-26 08:18:04 +02:00
|
|
|
}
|
2012-02-05 03:10:30 +01:00
|
|
|
final class RunConfiguration(val scalaVersion: Option[String], val app: xsbti.ApplicationID, val workingDirectory: File, val arguments: List[String])
|
2009-09-05 18:19:34 +02:00
|
|
|
|
2012-04-11 04:04:21 +02:00
|
|
|
import BootConfiguration.{appDirectoryName, baseDirectoryName, extractScalaVersion, ScalaDirectoryName, TestLoadScalaClasses, ScalaOrg}
|
2011-05-20 04:04:05 +02:00
|
|
|
class Launch private[xsbt](val bootDirectory: File, val lockBoot: Boolean, val ivyOptions: IvyOptions) extends xsbti.Launcher
|
2009-09-26 08:18:04 +02:00
|
|
|
{
|
2011-11-04 17:19:45 +01:00
|
|
|
import ivyOptions.{checksums => checksumsList, classifiers, repositories}
|
2009-10-24 19:07:42 +02:00
|
|
|
bootDirectory.mkdirs
|
2012-04-04 19:06:55 +02:00
|
|
|
private val scalaProviders = new Cache[(String, String), String, xsbti.ScalaProvider]((x, y) => getScalaProvider(x._1, x._2, y))
|
2011-04-11 06:44:28 +02:00
|
|
|
def getScala(version: String): xsbti.ScalaProvider = getScala(version, "")
|
2012-04-11 04:04:21 +02:00
|
|
|
def getScala(version: String, reason: String): xsbti.ScalaProvider = getScala(version, reason, ScalaOrg)
|
2012-04-05 12:19:49 +02:00
|
|
|
def getScala(version: String, reason: String, scalaOrg: String) = scalaProviders((scalaOrg, version), reason)
|
2012-02-05 03:10:30 +01:00
|
|
|
def app(id: xsbti.ApplicationID, version: String): xsbti.AppProvider = app(id, Option(version))
|
2012-04-12 23:31:24 +02:00
|
|
|
def app(id: xsbti.ApplicationID, scalaVersion: Option[String]): xsbti.AppProvider =
|
2012-04-05 12:19:49 +02:00
|
|
|
getAppProvider(id, scalaVersion, false)
|
|
|
|
|
|
2012-02-05 03:10:30 +01:00
|
|
|
val bootLoader = new BootFilteredLoader(getClass.getClassLoader)
|
|
|
|
|
val topLoader = jnaLoader(bootLoader)
|
2009-09-26 08:18:04 +02:00
|
|
|
|
2011-05-20 04:04:05 +02:00
|
|
|
val updateLockFile = if(lockBoot) Some(new File(bootDirectory, "sbt.boot.lock")) else None
|
2009-10-10 01:12:14 +02:00
|
|
|
|
2009-10-15 00:05:53 +02:00
|
|
|
def globalLock: xsbti.GlobalLock = Locks
|
2012-02-05 03:10:30 +01:00
|
|
|
def ivyHome = orNull(ivyOptions.ivyHome)
|
2011-07-20 03:29:05 +02:00
|
|
|
def ivyRepositories = repositories.toArray
|
2011-11-04 17:19:45 +01:00
|
|
|
def checksums = checksumsList.toArray[String]
|
2009-10-15 00:05:53 +02:00
|
|
|
|
2012-02-05 03:10:30 +01:00
|
|
|
def jnaLoader(parent: ClassLoader): ClassLoader =
|
|
|
|
|
{
|
|
|
|
|
val id = AppID("net.java.dev.jna", "jna", "3.2.3", "", toArray(Nil), false, array())
|
2012-04-11 04:04:21 +02:00
|
|
|
val configuration = makeConfiguration(ScalaOrg, None)
|
|
|
|
|
val jnaHome = appDirectory(new File(bootDirectory, baseDirectoryName(ScalaOrg, None)), id)
|
2012-02-05 03:10:30 +01:00
|
|
|
val module = appModule(id, None, false, "jna")
|
|
|
|
|
def makeLoader(): ClassLoader = {
|
|
|
|
|
val urls = toURLs(wrapNull(jnaHome.listFiles(JarFilter)))
|
|
|
|
|
val loader = new URLClassLoader(urls, bootLoader)
|
|
|
|
|
checkLoader(loader, module, "com.sun.jna.Function" :: Nil, loader)
|
|
|
|
|
}
|
|
|
|
|
val existingLoader =
|
|
|
|
|
if(jnaHome.exists)
|
|
|
|
|
try Some(makeLoader()) catch { case e: Exception => None }
|
|
|
|
|
else
|
|
|
|
|
None
|
|
|
|
|
existingLoader getOrElse {
|
|
|
|
|
update(module, "")
|
|
|
|
|
makeLoader()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
def checkLoader[T](loader: ClassLoader, module: ModuleDefinition, testClasses: Seq[String], ifValid: T): T =
|
|
|
|
|
{
|
|
|
|
|
val missing = getMissing(loader, testClasses)
|
|
|
|
|
if(missing.isEmpty)
|
|
|
|
|
ifValid
|
|
|
|
|
else
|
|
|
|
|
module.retrieveCorrupt(missing)
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-11 04:04:21 +02:00
|
|
|
private[this] def makeConfiguration(scalaOrg: String, version: Option[String]): UpdateConfiguration =
|
2012-04-04 19:06:55 +02:00
|
|
|
new UpdateConfiguration(bootDirectory, ivyOptions.ivyHome, scalaOrg, version, repositories, checksumsList)
|
2012-02-05 03:10:30 +01:00
|
|
|
|
|
|
|
|
final def getAppProvider(id: xsbti.ApplicationID, explicitScalaVersion: Option[String], forceAppUpdate: Boolean): xsbti.AppProvider =
|
|
|
|
|
locked(new Callable[xsbti.AppProvider] { def call = getAppProvider0(id, explicitScalaVersion, forceAppUpdate) })
|
|
|
|
|
|
|
|
|
|
@tailrec private[this] final def getAppProvider0(id: xsbti.ApplicationID, explicitScalaVersion: Option[String], forceAppUpdate: Boolean): xsbti.AppProvider =
|
|
|
|
|
{
|
|
|
|
|
val app = appModule(id, explicitScalaVersion, true, "app")
|
|
|
|
|
val baseDirs = (base: File) => appBaseDirs(base, id)
|
|
|
|
|
def retrieve() = {
|
|
|
|
|
val sv = update(app, "")
|
|
|
|
|
val scalaVersion = strictOr(explicitScalaVersion, sv)
|
2012-04-11 04:04:21 +02:00
|
|
|
new RetrievedModule(true, app, sv, baseDirs(scalaHome(ScalaOrg, scalaVersion)))
|
2012-02-05 03:10:30 +01:00
|
|
|
}
|
|
|
|
|
val retrievedApp =
|
|
|
|
|
if(forceAppUpdate)
|
|
|
|
|
retrieve()
|
|
|
|
|
else
|
2012-04-11 04:04:21 +02:00
|
|
|
existing(app, ScalaOrg, explicitScalaVersion, baseDirs) getOrElse retrieve()
|
2012-04-12 23:31:24 +02:00
|
|
|
|
2012-02-05 03:10:30 +01:00
|
|
|
val scalaVersion = getOrError(strictOr(explicitScalaVersion, retrievedApp.detectedScalaVersion), "No Scala version specified or detected")
|
|
|
|
|
val scalaProvider = getScala(scalaVersion, "(for " + id.name + ")")
|
|
|
|
|
|
|
|
|
|
val (missing, appProvider) = checkedAppProvider(id, retrievedApp, scalaProvider)
|
|
|
|
|
if(missing.isEmpty)
|
|
|
|
|
appProvider
|
|
|
|
|
else if(retrievedApp.fresh)
|
|
|
|
|
app.retrieveCorrupt(missing)
|
|
|
|
|
else
|
|
|
|
|
getAppProvider0(id, explicitScalaVersion, true)
|
|
|
|
|
}
|
2012-04-11 04:04:21 +02:00
|
|
|
def scalaHome(scalaOrg: String, scalaVersion: Option[String]): File = new File(bootDirectory, baseDirectoryName(scalaOrg, scalaVersion))
|
|
|
|
|
def appHome(id: xsbti.ApplicationID, scalaVersion: Option[String]): File = appDirectory(scalaHome(ScalaOrg, scalaVersion), id)
|
2012-02-05 03:10:30 +01:00
|
|
|
def checkedAppProvider(id: xsbti.ApplicationID, module: RetrievedModule, scalaProvider: xsbti.ScalaProvider): (Iterable[String], xsbti.AppProvider) =
|
|
|
|
|
{
|
|
|
|
|
val p = appProvider(id, module, scalaProvider, appHome(id, Some(scalaProvider.version)))
|
|
|
|
|
val missing = getMissing(p.loader, id.mainClass :: Nil)
|
|
|
|
|
(missing, p)
|
|
|
|
|
}
|
|
|
|
|
private[this] def locked[T](c: Callable[T]): T = Locks(orNull(updateLockFile), c)
|
2012-04-04 19:06:55 +02:00
|
|
|
def getScalaProvider(scalaOrg: String, scalaVersion: String, reason: String): xsbti.ScalaProvider =
|
|
|
|
|
locked(new Callable[xsbti.ScalaProvider] { def call = getScalaProvider0(scalaOrg, scalaVersion, reason) })
|
2012-02-05 03:10:30 +01:00
|
|
|
|
2012-04-12 23:31:24 +02:00
|
|
|
private[this] final def getScalaProvider0(scalaOrg: String, scalaVersion: String, reason: String) =
|
2012-02-05 03:10:30 +01:00
|
|
|
{
|
2012-04-04 19:06:55 +02:00
|
|
|
val scalaM = scalaModule(scalaOrg, scalaVersion)
|
|
|
|
|
val (scalaHome, lib) = scalaDirs(scalaM, scalaOrg, scalaVersion)
|
2012-02-05 03:10:30 +01:00
|
|
|
val baseDirs = lib :: Nil
|
|
|
|
|
def provider(retrieved: RetrievedModule): xsbti.ScalaProvider = {
|
|
|
|
|
val p = scalaProvider(scalaVersion, retrieved, topLoader, lib)
|
|
|
|
|
checkLoader(p.loader, retrieved.definition, TestLoadScalaClasses, p)
|
|
|
|
|
}
|
2012-04-11 04:04:21 +02:00
|
|
|
existing(scalaM, scalaOrg, Some(scalaVersion), _ => baseDirs) flatMap { mod =>
|
2012-02-05 03:10:30 +01:00
|
|
|
try Some(provider(mod))
|
|
|
|
|
catch { case e: Exception => None }
|
|
|
|
|
} getOrElse {
|
|
|
|
|
val scalaVersion = update(scalaM, reason)
|
|
|
|
|
provider( new RetrievedModule(true, scalaM, scalaVersion, baseDirs) )
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-11 04:04:21 +02:00
|
|
|
def existing(module: ModuleDefinition, scalaOrg: String, explicitScalaVersion: Option[String], baseDirs: File => List[File]): Option[RetrievedModule] =
|
2012-02-05 03:10:30 +01:00
|
|
|
{
|
|
|
|
|
val filter = new java.io.FileFilter {
|
2012-04-11 04:04:21 +02:00
|
|
|
val explicitName = explicitScalaVersion.map(sv => baseDirectoryName(scalaOrg, Some(sv)))
|
2012-02-05 03:10:30 +01:00
|
|
|
def accept(file: File) = file.isDirectory && explicitName.forall(_ == file.getName)
|
|
|
|
|
}
|
|
|
|
|
val retrieved = wrapNull(bootDirectory.listFiles(filter)) flatMap { scalaDir =>
|
|
|
|
|
val appDir = directory(scalaDir, module.target)
|
|
|
|
|
if(appDir.exists)
|
|
|
|
|
new RetrievedModule(false, module, extractScalaVersion(scalaDir), baseDirs(scalaDir)) :: Nil
|
|
|
|
|
else
|
|
|
|
|
Nil
|
|
|
|
|
}
|
|
|
|
|
retrieved.headOption
|
|
|
|
|
}
|
|
|
|
|
def directory(scalaDir: File, target: UpdateTarget): File = target match {
|
|
|
|
|
case _: UpdateScala => scalaDir
|
|
|
|
|
case ua: UpdateApp => appDirectory(scalaDir, ua.id.toID)
|
|
|
|
|
}
|
|
|
|
|
def appBaseDirs(scalaHome: File, id: xsbti.ApplicationID): List[File] =
|
|
|
|
|
{
|
|
|
|
|
val appHome = appDirectory(scalaHome, id)
|
|
|
|
|
val components = componentProvider(appHome)
|
|
|
|
|
appHome :: id.mainComponents.map(components.componentLocation).toList
|
|
|
|
|
}
|
|
|
|
|
def appDirectory(base: File, id: xsbti.ApplicationID): File =
|
|
|
|
|
new File(base, appDirectoryName(id, File.separator))
|
|
|
|
|
|
2012-04-04 19:06:55 +02:00
|
|
|
def scalaDirs(module: ModuleDefinition, scalaOrg: String, scalaVersion: String): (File, File) =
|
2012-02-05 03:10:30 +01:00
|
|
|
{
|
2012-04-11 04:04:21 +02:00
|
|
|
val scalaHome = new File(bootDirectory, baseDirectoryName(scalaOrg, Some(scalaVersion)))
|
|
|
|
|
val libDirectory = new File(scalaHome, ScalaDirectoryName)
|
2012-02-05 03:10:30 +01:00
|
|
|
(scalaHome, libDirectory)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def appProvider(appID: xsbti.ApplicationID, app: RetrievedModule, scalaProvider0: xsbti.ScalaProvider, appHome: File): xsbti.AppProvider = new xsbti.AppProvider
|
|
|
|
|
{
|
|
|
|
|
val scalaProvider = scalaProvider0
|
|
|
|
|
val id = appID
|
|
|
|
|
def mainClasspath = app.fullClasspath
|
|
|
|
|
lazy val loader = app.createLoader(scalaProvider.loader)
|
|
|
|
|
lazy val mainClass: Class[T] forSome { type T <: xsbti.AppMain } =
|
2009-08-21 14:12:43 +02:00
|
|
|
{
|
2012-02-05 03:10:30 +01:00
|
|
|
val c = Class.forName(id.mainClass, true, loader)
|
|
|
|
|
c.asSubclass(classOf[xsbti.AppMain])
|
2009-08-21 14:12:43 +02:00
|
|
|
}
|
2012-02-05 03:10:30 +01:00
|
|
|
def newMain(): xsbti.AppMain = mainClass.newInstance
|
|
|
|
|
|
|
|
|
|
lazy val components = componentProvider(appHome)
|
|
|
|
|
}
|
|
|
|
|
def componentProvider(appHome: File) = new ComponentProvider(appHome, lockBoot)
|
|
|
|
|
|
|
|
|
|
def scalaProvider(scalaVersion: String, module: RetrievedModule, parentLoader: ClassLoader, scalaLibDir: File): xsbti.ScalaProvider = new xsbti.ScalaProvider
|
|
|
|
|
{
|
|
|
|
|
def launcher = Launch.this
|
|
|
|
|
def version = scalaVersion
|
|
|
|
|
lazy val loader = module.createLoader(parentLoader)
|
|
|
|
|
|
|
|
|
|
def compilerJar = new File(scalaLibDir, CompilerModuleName + ".jar")
|
|
|
|
|
def libraryJar = new File(scalaLibDir, LibraryModuleName + ".jar")
|
|
|
|
|
def jars = module.fullClasspath
|
|
|
|
|
|
|
|
|
|
def app(id: xsbti.ApplicationID) = Launch.this.app(id, Some(scalaVersion))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def appModule(id: xsbti.ApplicationID, scalaVersion: Option[String], getClassifiers: Boolean, tpe: String): ModuleDefinition = new ModuleDefinition(
|
2012-04-11 04:04:21 +02:00
|
|
|
configuration = makeConfiguration(ScalaOrg, scalaVersion),
|
2012-02-05 03:10:30 +01:00
|
|
|
target = new UpdateApp(Application(id), if(getClassifiers) Value.get(classifiers.app) else Nil, tpe),
|
|
|
|
|
failLabel = id.name + " " + id.version,
|
|
|
|
|
extraClasspath = id.classpathExtra
|
|
|
|
|
)
|
2012-04-04 19:06:55 +02:00
|
|
|
def scalaModule(org: String, version: String): ModuleDefinition = new ModuleDefinition(
|
2012-04-11 04:04:21 +02:00
|
|
|
configuration = makeConfiguration(org, Some(version)),
|
2012-02-05 03:10:30 +01:00
|
|
|
target = new UpdateScala(Value.get(classifiers.forScala)),
|
|
|
|
|
failLabel = "Scala " + version,
|
|
|
|
|
extraClasspath = array()
|
|
|
|
|
)
|
|
|
|
|
def update(mm: ModuleDefinition, reason: String): Option[String] =
|
|
|
|
|
{
|
|
|
|
|
val result = ( new Update(mm.configuration) )(mm.target, reason)
|
|
|
|
|
if(result.success) result.scalaVersion else mm.retrieveFailed
|
2009-08-21 14:12:43 +02:00
|
|
|
}
|
2009-09-27 20:39:26 +02:00
|
|
|
}
|
2010-03-20 00:29:57 +01:00
|
|
|
object Launcher
|
|
|
|
|
{
|
2011-07-20 03:29:05 +02:00
|
|
|
def apply(bootDirectory: File, repositories: List[xsbti.Repository]): xsbti.Launcher =
|
2011-11-04 17:19:45 +01:00
|
|
|
apply(bootDirectory, IvyOptions(None, Classifiers(Nil, Nil), repositories, BootConfiguration.DefaultChecksums))
|
2010-05-14 00:38:55 +02:00
|
|
|
def apply(bootDirectory: File, ivyOptions: IvyOptions): xsbti.Launcher =
|
|
|
|
|
apply(bootDirectory, ivyOptions, GetLocks.find)
|
|
|
|
|
def apply(bootDirectory: File, ivyOptions: IvyOptions, locks: xsbti.GlobalLock): xsbti.Launcher =
|
2011-05-20 04:04:05 +02:00
|
|
|
new Launch(bootDirectory, true, ivyOptions) {
|
2010-03-20 00:29:57 +01:00
|
|
|
override def globalLock = locks
|
|
|
|
|
}
|
|
|
|
|
def apply(explicit: LaunchConfiguration): xsbti.Launcher =
|
2011-05-20 04:04:05 +02:00
|
|
|
new Launch(explicit.boot.directory, explicit.boot.lock, explicit.ivyConfiguration)
|
2010-03-20 00:29:57 +01:00
|
|
|
def defaultAppProvider(baseDirectory: File): xsbti.AppProvider = getAppProvider(baseDirectory, Configuration.configurationOnClasspath)
|
|
|
|
|
def getAppProvider(baseDirectory: File, configLocation: URL): xsbti.AppProvider =
|
|
|
|
|
{
|
|
|
|
|
val parsed = ResolvePaths(Configuration.parse(configLocation, baseDirectory), baseDirectory)
|
|
|
|
|
Initialize.process(parsed.boot.properties, parsed.appProperties, Initialize.selectQuick)
|
2010-08-12 00:50:44 +02:00
|
|
|
val config = ResolveValues(parsed)
|
2010-03-20 00:29:57 +01:00
|
|
|
val launcher = apply(config)
|
2012-02-05 03:10:30 +01:00
|
|
|
launcher.app(config.app.toID, orNull(config.getScalaVersion))
|
2010-03-20 00:29:57 +01:00
|
|
|
}
|
|
|
|
|
}
|
2011-05-20 04:04:05 +02:00
|
|
|
class ComponentProvider(baseDirectory: File, lockBoot: Boolean) extends xsbti.ComponentProvider
|
2009-09-27 20:39:26 +02:00
|
|
|
{
|
|
|
|
|
def componentLocation(id: String): File = new File(baseDirectory, id)
|
2012-02-05 03:10:30 +01:00
|
|
|
def component(id: String) = wrapNull(componentLocation(id).listFiles).filter(_.isFile)
|
2009-09-27 20:39:26 +02:00
|
|
|
def defineComponent(id: String, files: Array[File]) =
|
|
|
|
|
{
|
|
|
|
|
val location = componentLocation(id)
|
|
|
|
|
if(location.exists)
|
|
|
|
|
throw new BootException("Cannot redefine component. ID: " + id + ", files: " + files.mkString(","))
|
|
|
|
|
else
|
2009-10-18 04:40:02 +02:00
|
|
|
Copy(files.toList, location)
|
2009-09-27 20:39:26 +02:00
|
|
|
}
|
2011-07-02 05:38:03 +02:00
|
|
|
def addToComponent(id: String, files: Array[File]): Boolean =
|
|
|
|
|
Copy(files.toList, componentLocation(id))
|
2011-05-20 04:04:05 +02:00
|
|
|
def lockFile = if(lockBoot) ComponentProvider.lockFile(baseDirectory) else null // null for the Java interface
|
2009-10-15 00:05:53 +02:00
|
|
|
}
|
|
|
|
|
object ComponentProvider
|
|
|
|
|
{
|
|
|
|
|
def lockFile(baseDirectory: File) =
|
2009-10-11 04:01:03 +02:00
|
|
|
{
|
|
|
|
|
baseDirectory.mkdirs()
|
|
|
|
|
new File(baseDirectory, "sbt.components.lock")
|
|
|
|
|
}
|
2009-10-16 00:10:11 +02:00
|
|
|
}
|