mirror of
https://github.com/sbt/sbt.git
synced 2026-09-03 16:39:24 +02:00
Cache now takes in account of the parent of the classloader
This commit is contained in:
@@ -943,13 +943,22 @@ private[sbt] 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("Use BuildUtil.apply", "0.13.0")
|
||||
|
||||
Reference in New Issue
Block a user