From 3e3519b3a738c6d272cee3791271baf8567003ff Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Wed, 27 Jan 2010 20:39:07 -0500 Subject: [PATCH] cleanup --- launch/Cache.scala | 21 ++++----------------- project/build/ProguardProject.scala | 4 ++-- tasks/standard/Compile.scala | 4 +++- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/launch/Cache.scala b/launch/Cache.scala index e2cfe1c7a..eb4778105 100644 --- a/launch/Cache.scala +++ b/launch/Cache.scala @@ -2,27 +2,14 @@ package xsbt.boot import java.lang.ref.{Reference, SoftReference} import java.util.HashMap +import java.lang.ref.{Reference, SoftReference} final class Cache[K,V](create: K => V) extends NotNull { private[this] val delegate = new HashMap[K,Reference[V]] - def apply(k: K): V = - { - val existingRef = delegate.get(k) - if(existingRef == null) - newEntry(k) - else - { - val existing = existingRef.get - if(existing == null) - { - println("Cache value for '" + k + "' was garbage collected, recreating it...") - newEntry(k) - } - else - existing - } - } + def apply(k: K): V = getFromReference(k, delegate.get(k)) + private[this] def getFromReference(k: K, existingRef: Reference[V]) = if(existingRef eq null) newEntry(k) else get(k, existingRef.get) + private[this] def get(k: K, existing: V) = if(existing == null) newEntry(k) else existing private[this] def newEntry(k: K): V = { val v = create(k) diff --git a/project/build/ProguardProject.scala b/project/build/ProguardProject.scala index d16d2985c..3901e47ab 100644 --- a/project/build/ProguardProject.scala +++ b/project/build/ProguardProject.scala @@ -50,9 +50,9 @@ trait ProguardProject extends BasicScalaProject keepClasses.map("-keep public class " + _ + " {\n public * ;\n}") ++ mapInJars(inJars) ++ Seq("-injars " + mkpath(rawJarPath.asFile), - mapOutJar(outJar)) ++ + mapOutJar(outJar)) ++ mapLibraryJars(libraryJars) ++ - mainClass.map(main => keepMain.stripMargin.format(main)).toList + mainClass.map(main => keepMain.stripMargin.format(main)).toList lines.mkString("\n") } diff --git a/tasks/standard/Compile.scala b/tasks/standard/Compile.scala index 3dcf01bc8..ecdbd4791 100644 --- a/tasks/standard/Compile.scala +++ b/tasks/standard/Compile.scala @@ -111,9 +111,11 @@ class AggressiveCompile(val cacheDirectory: File, val compilerTask: Task[Analyzi val apiChanged = sources filter { src => !sameAPI(previousAPIMap, newAPIMap, src) } log.info("Sources with API changes:\n\t" + apiChanged.mkString("\n\t")) val finalAPIMap = - if(apiChanged.isEmpty || apiChanged.size == sourceChanges.checked.size) newAPIMap + // if either nothing changed or everything was recompiled, stop here + if(apiChanged.isEmpty || sources.size == sourceChanges.checked.size) newAPIMap else { + //val changedNames = TopLevel.nameChanges(newAPIMap.values, previousAPIMap.values) InvalidateTransitive.clean(tracker, FileUtilities.delete, transitiveIfNeeded) val sources = transitiveIfNeeded.invalid ** sourceChanges.checked log.info("All sources invalidated by API changes:\n\t" + sources.mkString("\n\t"))