mirror of https://github.com/sbt/sbt.git
Add scala reflect layer
Not caching scala reflect is extremely painful if the build uses scalatest. It adds O(1second) to my watch performance benchmarks. It actually made sbt 1.3.0 much slower than 0.13.17
This commit is contained in:
parent
cf73bbbafc
commit
5faf78af96
|
|
@ -105,7 +105,7 @@ private[sbt] object ClassLoaders {
|
|||
}
|
||||
/*
|
||||
* Create a layered classloader. There are up to four layers:
|
||||
* 1) the scala instance class loader
|
||||
* 1) the scala instance class loader (may actually be two layers if scala-reflect is used)
|
||||
* 2) the resource layer
|
||||
* 3) the dependency jars
|
||||
* 4) the rest of the classpath
|
||||
|
|
@ -135,11 +135,18 @@ private[sbt] object ClassLoaders {
|
|||
val scalaLibraryLayer = layer(si.libraryJars, interfaceLoader, cache, resources, tmp)
|
||||
val cpFiles = fullCP.map(_._1)
|
||||
|
||||
val scalaReflectJar = allDependencies.find(_.getName == "scala-reflect.jar")
|
||||
val scalaReflectLayer = scalaReflectJar
|
||||
.map { file =>
|
||||
layer(file :: Nil, scalaLibraryLayer, cache, resources, tmp)
|
||||
}
|
||||
.getOrElse(scalaLibraryLayer)
|
||||
|
||||
// layer 2 (resources)
|
||||
val resourceLayer =
|
||||
if (layerDependencies)
|
||||
getResourceLayer(cpFiles, resourceCP, scalaLibraryLayer, cache, resources)
|
||||
else scalaLibraryLayer
|
||||
getResourceLayer(cpFiles, resourceCP, scalaReflectLayer, cache, resources)
|
||||
else scalaReflectLayer
|
||||
|
||||
// layer 3 (optional if in the test config and the runtime layer is not shared)
|
||||
val dependencyLayer =
|
||||
|
|
@ -148,8 +155,8 @@ private[sbt] object ClassLoaders {
|
|||
|
||||
// layer 4
|
||||
val filteredSet =
|
||||
if (layerDependencies) allDependencies.toSet ++ si.libraryJars
|
||||
else Set(si.libraryJars: _*)
|
||||
if (layerDependencies) allDependencies.toSet ++ si.libraryJars ++ scalaReflectJar
|
||||
else Set(si.libraryJars ++ scalaReflectJar: _*)
|
||||
val dynamicClasspath = cpFiles.filterNot(filteredSet)
|
||||
new LayeredClassLoader(dynamicClasspath, dependencyLayer, resources, tmp)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue