support earlier launchers

This commit is contained in:
Mark Harrah 2011-04-23 15:58:59 -04:00
parent 85835c6d22
commit 8836b83ba3
4 changed files with 13 additions and 3 deletions

View File

@ -13,6 +13,11 @@ object CommandSupport
{
def logger(s: State) = s get Keys.logged getOrElse ConsoleLogger()
// slightly better fallback in case of older launcher
def bootDirectory(state: State): File =
try { state.configuration.provider.scalaProvider.launcher.bootDirectory }
catch { case e: NoSuchMethodError => new File(".").getAbsoluteFile }
private def canRead = (_: File).canRead
def notReadable(files: Seq[File]): Seq[File] = files filterNot canRead
def readable(files: Seq[File]): Seq[File] = files filter canRead

View File

@ -498,7 +498,7 @@ object Classpaths
moduleID <<= normalizedName.identity,
defaultConfiguration in GlobalScope :== Some(Configurations.Compile),
defaultConfigurationMapping in GlobalScope <<= defaultConfiguration{ case Some(d) => "*->" + d.name; case None => "*->*" },
ivyPaths <<= (baseDirectory, appConfiguration) { (base, app) => new IvyPaths(base, Option(app.provider.scalaProvider.launcher.ivyHome)) },
ivyPaths <<= (baseDirectory, appConfiguration) { (base, app) => new IvyPaths(base, bootIvyHome(app)) },
otherResolvers <<= publishTo(_.toList),
projectResolver <<= projectResolverTask,
projectDependencies <<= projectDependenciesTask,
@ -769,6 +769,11 @@ object Classpaths
case _ => arts
}
}
// support earlier launchers
def bootIvyHome(app: xsbti.AppConfiguration): Option[File] =
try { Option(app.provider.scalaProvider.launcher.ivyHome) }
catch { case _: NoSuchMethodError => None }
}
trait BuildExtra

View File

@ -14,7 +14,7 @@ object IvyConsole
lazy val command =
Command.command(Name) { state =>
val Dependencies(managed, repos, unmanaged) = parseDependencies(state.remainingCommands, CommandSupport.logger(state))
val base = new File(state.configuration.provider.scalaProvider.launcher.bootDirectory, Name)
val base = new File(CommandSupport.bootDirectory(state), Name)
IO.createDirectory(base)
val (eval, structure) = Load.defaultLoad(state, base, CommandSupport.logger(state))

View File

@ -16,7 +16,7 @@ object Script
val scriptArg = state.remainingCommands.headOption getOrElse error("No script file specified")
val script = new File(scriptArg).getAbsoluteFile
val hash = halve(Hash.toHex(Hash(script.getAbsolutePath)))
val base = new File(state.configuration.provider.scalaProvider.launcher.bootDirectory, hash)
val base = new File(CommandSupport.bootDirectory(state), hash)
IO.createDirectory(base)
val (eval, structure) = Load.defaultLoad(state, base, CommandSupport.logger(state))