From 8325c28bb27b4bae94f9db1808909d9a8fef0cd0 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Mon, 9 Nov 2009 22:02:53 -0500 Subject: [PATCH] Fix issue where compiler interface was poorly cached --- ivy/ComponentManager.scala | 13 ++++++++++++- ivy/IvyCache.scala | 3 +-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ivy/ComponentManager.scala b/ivy/ComponentManager.scala index 0056ace7a..fc4606f6d 100644 --- a/ivy/ComponentManager.scala +++ b/ivy/ComponentManager.scala @@ -55,7 +55,7 @@ class ComponentManager(globalLock: xsbti.GlobalLock, provider: xsbti.ComponentPr /** Retrieve the file for component 'id' from the local repository. */ private def update(id: String): Unit = IvyCache.withCachedJar(sbtModuleID(id), log)(jar => define(id, Seq(jar)) ) - private def sbtModuleID(id: String) = ModuleID("org.scala-tools.sbt", id, xsbti.Versions.Sbt) + private def sbtModuleID(id: String) = ModuleID("org.scala-tools.sbt", id, ComponentManager.stampedVersion) /** Install the files for component 'id' to the local repository. This is usually used after writing files to the directory returned by 'location'. */ def cache(id: String): Unit = IvyCache.cacheJar(sbtModuleID(id), file(id)(IfMissing.Fail), log) def clearCache(id: String): Unit = lockGlobalCache { IvyCache.clearCachedJar(sbtModuleID(id), log) } @@ -69,4 +69,15 @@ object IfMissing { object Fail extends IfMissing final class Define(val cache: Boolean, define: => Unit) extends IfMissing { def apply() = define } +} +object ComponentManager +{ + lazy val (version, timestamp) = + { + val properties = new java.util.Properties + val propertiesStream = getClass.getResourceAsStream("/xsbt.version.properties") + try { properties.load(propertiesStream) } finally { propertiesStream.close() } + (properties.getProperty("version"), properties.getProperty("timestamp")) + } + lazy val stampedVersion = version + "_" + timestamp } \ No newline at end of file diff --git a/ivy/IvyCache.scala b/ivy/IvyCache.scala index e3f0044bc..cfb829458 100644 --- a/ivy/IvyCache.scala +++ b/ivy/IvyCache.scala @@ -52,8 +52,7 @@ object IvyCache copyTo } - /** Get the location of the cached jar for the given ID in the Ivy cache. If the jar is not in the cache, NotInCache is thrown - * TODO: locking.*/ + /** Get the location of the cached jar for the given ID in the Ivy cache. If the jar is not in the cache, NotInCache is thrown .*/ def withCachedJar[T](id: ModuleID, log: IvyLogger)(f: File => T): T = { val cachedFile =