From 97f252aaaf1ed78325770ac6847473f23706df4f Mon Sep 17 00:00:00 2001 From: dmharrah Date: Thu, 13 Aug 2009 03:33:21 +0000 Subject: [PATCH] Tiny speedup to boot when update required git-svn-id: https://simple-build-tool.googlecode.com/svn/trunk@953 d89573ee-9141-11dd-94d4-bdf5e562f29c --- boot/src/main/scala/Update.scala | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/boot/src/main/scala/Update.scala b/boot/src/main/scala/Update.scala index 91c4754bc..b63d782ef 100644 --- a/boot/src/main/scala/Update.scala +++ b/boot/src/main/scala/Update.scala @@ -5,7 +5,7 @@ package sbt.boot import java.io.{File, FileWriter, PrintWriter, Writer} -import org.apache.ivy.{core, plugins, util} +import org.apache.ivy.{core, plugins, util, Ivy} import core.LogOptions import core.cache.DefaultRepositoryCacheManager import core.event.EventManager @@ -64,6 +64,14 @@ private final class Update(bootDirectory: File, sbtVersion: String, scalaVersion } /** Runs update for the specified target (updates either the scala or sbt jars for building the project) */ private def update(target: UpdateTarget.Value) + { + val settings = new IvySettings + val ivy = Ivy.newInstance(settings) + ivy.pushContext() + try { update(target, settings) } + finally { ivy.popContext() } + } + private def update(target: UpdateTarget.Value, settings: IvySettings) { import Configuration.Visibility.PUBLIC // the actual module id here is not that important @@ -76,25 +84,24 @@ private final class Update(bootDirectory: File, sbtVersion: String, scalaVersion case UpdateScala => addDependency(moduleID, ScalaOrg, CompilerModuleName, scalaVersion, "default") addDependency(moduleID, ScalaOrg, LibraryModuleName, scalaVersion, "default") - update(moduleID, target, false) + update(settings, moduleID, target, false) case UpdateSbt => addDependency(moduleID, SbtOrg, SbtModuleName, sbtVersion, scalaVersion) - try { update(moduleID, target, false) } + try { update(settings, moduleID, target, false) } catch { // unfortunately, there is not a more specific exception thrown when a configuration does not exist, // so we always retry after cleaning the ivy file for this version of sbt on in case it is a newer version // of Scala than when this version of sbt was initially published case e: RuntimeException => - update(moduleID, target, true) + update(settings, moduleID, target, true) } } } /** Runs the resolve and retrieve for the given moduleID, which has had its dependencies added already. */ - private def update(moduleID: DefaultModuleDescriptor, target: UpdateTarget.Value, cleanExisting: Boolean) + private def update(settings: IvySettings, moduleID: DefaultModuleDescriptor, target: UpdateTarget.Value, cleanExisting: Boolean) { val eventManager = new EventManager - val settings = new IvySettings addResolvers(settings, scalaVersion, target) settings.setDefaultConflictManager(settings.getConflictManager(ConflictManagerName)) settings.setBaseDir(bootDirectory)