mirror of https://github.com/sbt/sbt.git
Merge pull request #5734 from eatkins/defines-class-cache
Cache jar classpath entries between commands
This commit is contained in:
commit
df1eae1a87
|
|
@ -104,7 +104,6 @@ import sbt.SlashSyntax0._
|
||||||
import sbt.internal.inc.{
|
import sbt.internal.inc.{
|
||||||
Analysis,
|
Analysis,
|
||||||
AnalyzingCompiler,
|
AnalyzingCompiler,
|
||||||
Locate,
|
|
||||||
ManagedLoggedReporter,
|
ManagedLoggedReporter,
|
||||||
MixedAnalyzingCompiler,
|
MixedAnalyzingCompiler,
|
||||||
ScalaInstance
|
ScalaInstance
|
||||||
|
|
@ -759,13 +758,11 @@ object Defaults extends BuildCommon {
|
||||||
Vector("-Ypickle-java", "-Ypickle-write", converter.toPath(earlyOutput.value).toString) ++ old
|
Vector("-Ypickle-java", "-Ypickle-write", converter.toPath(earlyOutput.value).toString) ++ old
|
||||||
else old
|
else old
|
||||||
},
|
},
|
||||||
|
persistJarClasspath :== true,
|
||||||
|
classpathDefinesClassCache := VirtualFileValueCache.definesClassCache(fileConverter.value),
|
||||||
classpathEntryDefinesClassVF := {
|
classpathEntryDefinesClassVF := {
|
||||||
val converter = fileConverter.value
|
(if (persistJarClasspath.value) classpathDefinesClassCache.value
|
||||||
val f = VirtualFileValueCache(converter)({ x: VirtualFile =>
|
else VirtualFileValueCache.definesClassCache(fileConverter.value)).get
|
||||||
if (x.name.toString != "rt.jar") Locate.definesClass(x)
|
|
||||||
else ((_: String) => false): DefinesClass
|
|
||||||
}).get
|
|
||||||
f
|
|
||||||
},
|
},
|
||||||
compileIncSetup := compileIncSetupTask.value,
|
compileIncSetup := compileIncSetupTask.value,
|
||||||
console := consoleTask.value,
|
console := consoleTask.value,
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,8 @@ object Keys {
|
||||||
val compilerCache = taskKey[GlobalsCache]("Cache of scala.tools.nsc.Global instances. This should typically be cached so that it isn't recreated every task run.").withRank(DTask)
|
val compilerCache = taskKey[GlobalsCache]("Cache of scala.tools.nsc.Global instances. This should typically be cached so that it isn't recreated every task run.").withRank(DTask)
|
||||||
val stateCompilerCache = AttributeKey[GlobalsCache]("stateCompilerCache", "Internal use: Global cache.")
|
val stateCompilerCache = AttributeKey[GlobalsCache]("stateCompilerCache", "Internal use: Global cache.")
|
||||||
val classpathEntryDefinesClass = taskKey[File => DefinesClass]("Internal use: provides a function that determines whether the provided file contains a given class.").withRank(Invisible)
|
val classpathEntryDefinesClass = taskKey[File => DefinesClass]("Internal use: provides a function that determines whether the provided file contains a given class.").withRank(Invisible)
|
||||||
|
private[sbt] val classpathDefinesClassCache = settingKey[VirtualFileValueCache[DefinesClass]]("Internal use: a cache of jar classpath entries that persists across command evaluations.").withRank(Invisible)
|
||||||
|
val persistJarClasspath = settingKey[Boolean]("Toggles whether or not to cache jar classpath entries between command evaluations")
|
||||||
val classpathEntryDefinesClassVF = taskKey[VirtualFile => DefinesClass]("Internal use: provides a function that determines whether the provided file contains a given class.").withRank(Invisible)
|
val classpathEntryDefinesClassVF = taskKey[VirtualFile => DefinesClass]("Internal use: provides a function that determines whether the provided file contains a given class.").withRank(Invisible)
|
||||||
val doc = taskKey[File]("Generates API documentation.").withRank(AMinusTask)
|
val doc = taskKey[File]("Generates API documentation.").withRank(AMinusTask)
|
||||||
val copyResources = taskKey[Seq[(File, File)]]("Copies resources to the output directory.").withRank(AMinusTask)
|
val copyResources = taskKey[Seq[(File, File)]]("Copies resources to the output directory.").withRank(AMinusTask)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,9 @@ package internal
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
import sbt.internal.inc.Stamper
|
import sbt.internal.inc.Stamper
|
||||||
import xsbti.{ FileConverter, VirtualFile, VirtualFileRef }
|
import xsbti.{ FileConverter, VirtualFile, VirtualFileRef }
|
||||||
|
import xsbti.compile.DefinesClass
|
||||||
import xsbti.compile.analysis.{ Stamp => XStamp }
|
import xsbti.compile.analysis.{ Stamp => XStamp }
|
||||||
|
import sbt.internal.inc.Locate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache based on path and its stamp.
|
* Cache based on path and its stamp.
|
||||||
|
|
@ -22,6 +24,12 @@ sealed trait VirtualFileValueCache[A] {
|
||||||
}
|
}
|
||||||
|
|
||||||
object VirtualFileValueCache {
|
object VirtualFileValueCache {
|
||||||
|
def definesClassCache(converter: FileConverter): VirtualFileValueCache[DefinesClass] = {
|
||||||
|
apply(converter) { x: VirtualFile =>
|
||||||
|
if (x.name.toString != "rt.jar") Locate.definesClass(x)
|
||||||
|
else (_: String) => false
|
||||||
|
}
|
||||||
|
}
|
||||||
def apply[A](converter: FileConverter)(f: VirtualFile => A): VirtualFileValueCache[A] = {
|
def apply[A](converter: FileConverter)(f: VirtualFile => A): VirtualFileValueCache[A] = {
|
||||||
import collection.mutable.{ HashMap, Map }
|
import collection.mutable.{ HashMap, Map }
|
||||||
val stampCache: Map[VirtualFileRef, (Long, XStamp)] = new HashMap
|
val stampCache: Map[VirtualFileRef, (Long, XStamp)] = new HashMap
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue