mirror of https://github.com/sbt/sbt.git
Cache now takes in account of the parent of the classloader
This commit is contained in:
parent
81bff4b67b
commit
4900c71ff9
|
|
@ -974,13 +974,22 @@ object Load {
|
|||
final class EvaluatedConfigurations(val eval: Eval, val settings: Seq[Setting[_]])
|
||||
final case class InjectSettings(global: Seq[Setting[_]], project: Seq[Setting[_]], projectLoaded: ClassLoader => Seq[Setting[_]]) {
|
||||
import java.net.URLClassLoader
|
||||
private val cache: mutable.Map[Set[URL], Seq[Setting[_]]] = mutable.Map.empty
|
||||
private val cache: mutable.Map[List[URL], Seq[Setting[_]]] = mutable.Map.empty
|
||||
// Cache based on the underlying URL values of the classloader
|
||||
def cachedProjectLoaded(cl: ClassLoader): Seq[Setting[_]] =
|
||||
cl match {
|
||||
case cl: URLClassLoader => cache.getOrElseUpdate(cl.getURLs.toSet, projectLoaded(cl))
|
||||
case cl: URLClassLoader => cache.getOrElseUpdate(classLoaderToList(cl), projectLoaded(cl))
|
||||
case _ => projectLoaded(cl)
|
||||
}
|
||||
private def classLoaderToList(cl: ClassLoader): List[URL] =
|
||||
cl match {
|
||||
case cl: URLClassLoader =>
|
||||
cl.getURLs.toList ::: (Option(cl.getParent) match {
|
||||
case Some(x) => classLoaderToList(x)
|
||||
case _ => Nil
|
||||
})
|
||||
case _ => Nil
|
||||
}
|
||||
}
|
||||
|
||||
@deprecated("LoadedDefinitions is now top-level", "0.13.0")
|
||||
|
|
|
|||
Loading…
Reference in New Issue