diff --git a/compile/ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala b/compile/ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala index a93f91deb..de0c9d692 100644 --- a/compile/ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala +++ b/compile/ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala @@ -26,11 +26,11 @@ object ComponentCompiler { } } - def interfaceProvider(manager: ComponentManager, ivyConfiguration: IvyConfiguration, sourcesModule: ModuleID, bootDirectory: File): CompilerInterfaceProvider = new CompilerInterfaceProvider { + def interfaceProvider(manager: ComponentManager, ivyConfiguration: IvyConfiguration, sourcesModule: ModuleID): CompilerInterfaceProvider = new CompilerInterfaceProvider { def apply(scalaInstance: xsbti.compile.ScalaInstance, log: Logger): File = { // this is the instance used to compile the interface component - val componentCompiler = new IvyComponentCompiler(new RawCompiler(scalaInstance, ClasspathOptions.auto, log), manager, ivyConfiguration, sourcesModule, bootDirectory, log) + val componentCompiler = new IvyComponentCompiler(new RawCompiler(scalaInstance, ClasspathOptions.auto, log), manager, ivyConfiguration, sourcesModule, log) log.debug("Getting " + sourcesModule + " from component compiler for Scala " + scalaInstance.version) componentCompiler() } @@ -85,7 +85,7 @@ class ComponentCompiler(compiler: RawCompiler, manager: ComponentManager) { * The compiled classes are cached using the provided component manager according * to the actualVersion field of the RawCompiler. */ -private[compiler] class IvyComponentCompiler(compiler: RawCompiler, manager: ComponentManager, ivyConfiguration: IvyConfiguration, sourcesModule: ModuleID, bootDirectory: File, log: Logger) { +private[compiler] class IvyComponentCompiler(compiler: RawCompiler, manager: ComponentManager, ivyConfiguration: IvyConfiguration, sourcesModule: ModuleID, log: Logger) { import ComponentCompiler._ private val sbtOrg = xsbti.ArtifactInfo.SbtOrganization @@ -94,7 +94,6 @@ private[compiler] class IvyComponentCompiler(compiler: RawCompiler, manager: Com private val ivySbt: IvySbt = new IvySbt(ivyConfiguration) private val sbtVersion = ComponentManager.version private val buffered = new BufferedLogger(FullLogger(log)) - private val retrieveDirectory = new File(s"$bootDirectory/scala-${compiler.scalaInstance.version}/$sbtOrg/sbt/$sbtVersion/compiler-interface-srcs/${sourcesModule.name}/${sourcesModule.revision}") def apply(): File = { val binID = binaryID(sourcesModule.name) @@ -113,14 +112,18 @@ private[compiler] class IvyComponentCompiler(compiler: RawCompiler, manager: Com val xsbtiJars = manager.files(xsbtiID)(IfMissing.Fail) buffered bufferQuietly { - (update(getModule(sourcesModule))(_.getName endsWith "-sources.jar")) match { - case Some(sources) => - AnalyzingCompiler.compileSources(sources, targetJar, xsbtiJars, sourcesModule.name, compiler, log) - manager.define(binID, Seq(targetJar)) - case None => - throw new InvalidComponent(s"Couldn't retrieve source module: $sourcesModule") + IO.withTemporaryDirectory { retrieveDirectory => + (update(getModule(sourcesModule), retrieveDirectory)(_.getName endsWith "-sources.jar")) match { + case Some(sources) => + AnalyzingCompiler.compileSources(sources, targetJar, xsbtiJars, sourcesModule.name, compiler, log) + manager.define(binID, Seq(targetJar)) + + case None => + throw new InvalidComponent(s"Couldn't retrieve source module: $sourcesModule") + } } + } } @@ -158,7 +161,7 @@ private[compiler] class IvyComponentCompiler(compiler: RawCompiler, manager: Com s"unknown" } - private def update(module: ivySbt.Module)(predicate: File => Boolean): Option[Seq[File]] = { + private def update(module: ivySbt.Module, retrieveDirectory: File)(predicate: File => Boolean): Option[Seq[File]] = { val retrieveConfiguration = new RetrieveConfiguration(retrieveDirectory, Resolver.defaultRetrievePattern, false) val updateConfiguration = new UpdateConfiguration(Some(retrieveConfiguration), true, UpdateLogging.DownloadOnly) diff --git a/main/actions/src/main/scala/sbt/Compiler.scala b/main/actions/src/main/scala/sbt/Compiler.scala index 41c9214b7..9349e422a 100644 --- a/main/actions/src/main/scala/sbt/Compiler.scala +++ b/main/actions/src/main/scala/sbt/Compiler.scala @@ -108,8 +108,7 @@ object Compiler { { val launcher = app.provider.scalaProvider.launcher val componentManager = new ComponentManager(launcher.globalLock, app.provider.components, Option(launcher.ivyHome), log) - val bootDirectory = launcher.bootDirectory - val provider = ComponentCompiler.interfaceProvider(componentManager, ivyConfiguration, sourcesModule, bootDirectory) + val provider = ComponentCompiler.interfaceProvider(componentManager, ivyConfiguration, sourcesModule) new AnalyzingCompiler(instance, provider, cpOptions) }