mirror of https://github.com/sbt/sbt.git
Fix implementation of `LoadBuildConfiguration`
It mainly does three things: * Clean up the implementation, removing unused values like `globalPluginDefs`. * Make the implementation more readable. * And the big one: Remove the creation of a classloader that we were instantiating but whose value we were throwing away. This has an impact in performance, but I'm yet to benchmark how much it is.
This commit is contained in:
parent
ab5e875ce4
commit
90782b1cd0
|
|
@ -138,6 +138,11 @@ final case class PluginData(
|
|||
val classpath: Seq[Attributed[File]] = definitionClasspath ++ dependencyClasspath
|
||||
}
|
||||
|
||||
object PluginData {
|
||||
private[sbt] def apply(dependencyClasspath: Def.Classpath): PluginData =
|
||||
PluginData(dependencyClasspath, Nil, None, None, Nil)
|
||||
}
|
||||
|
||||
object EvaluateTask {
|
||||
import std.Transform
|
||||
import Keys.state
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import Keys.{
|
|||
thisProjectRef,
|
||||
update
|
||||
}
|
||||
import tools.nsc.reporters.ConsoleReporter
|
||||
import scala.tools.nsc.reporters.ConsoleReporter
|
||||
import sbt.internal.util.{ Attributed, Settings, ~> }
|
||||
import sbt.util.{ Eval => Ev, Show }
|
||||
import sbt.internal.util.Attributed.data
|
||||
|
|
@ -909,13 +909,15 @@ private[sbt] object Load {
|
|||
def pluginDefinitionLoader(config: LoadBuildConfiguration, pluginData: PluginData): (Seq[Attributed[File]], ClassLoader) =
|
||||
pluginDefinitionLoader(config, pluginData.dependencyClasspath, pluginData.definitionClasspath)
|
||||
|
||||
def buildPluginClasspath(config: LoadBuildConfiguration,
|
||||
depcp: Seq[Attributed[File]]): Def.Classpath = {
|
||||
if (depcp.isEmpty) config.classpath
|
||||
else (depcp ++ config.classpath).distinct
|
||||
}
|
||||
|
||||
def pluginDefinitionLoader(config: LoadBuildConfiguration, depcp: Seq[Attributed[File]], defcp: Seq[Attributed[File]]): (Seq[Attributed[File]], ClassLoader) =
|
||||
{
|
||||
val definitionClasspath =
|
||||
if (depcp.isEmpty)
|
||||
config.classpath
|
||||
else
|
||||
(depcp ++ config.classpath).distinct
|
||||
val definitionClasspath = buildPluginClasspath(config, depcp)
|
||||
val pm = config.pluginManagement
|
||||
// only the dependencyClasspath goes in the common plugin class loader ...
|
||||
def addToLoader() = pm.loader add Path.toURLs(data(depcp))
|
||||
|
|
@ -1000,7 +1002,7 @@ private[sbt] object Load {
|
|||
|
||||
final case class LoadBuildConfiguration(
|
||||
stagingDirectory: File,
|
||||
classpath: Seq[Attributed[File]],
|
||||
classpath: Def.Classpath,
|
||||
loader: ClassLoader,
|
||||
compilers: Compilers,
|
||||
evalPluginDef: (BuildStructure, State) => PluginData,
|
||||
|
|
@ -1012,21 +1014,23 @@ final case class LoadBuildConfiguration(
|
|||
extraBuilds: Seq[URI],
|
||||
log: Logger
|
||||
) {
|
||||
lazy val (globalPluginClasspath, _) = Load.pluginDefinitionLoader(this, Load.globalPluginClasspath(globalPlugin))
|
||||
lazy val globalPluginClasspath: Def.Classpath =
|
||||
Load.buildPluginClasspath(this, Load.globalPluginClasspath(globalPlugin))
|
||||
|
||||
private[sbt] lazy val globalPluginDefs = {
|
||||
lazy val detectedGlobalPlugins: DetectedPlugins = {
|
||||
val pluginData = globalPlugin match {
|
||||
case Some(x) => PluginData(x.data.fullClasspath, x.data.internalClasspath, Some(x.data.resolvers), Some(x.data.updateReport), Nil)
|
||||
case None => PluginData(globalPluginClasspath, Nil, None, None, Nil)
|
||||
case Some(info) =>
|
||||
val data = info.data
|
||||
PluginData(data.fullClasspath, data.internalClasspath, Some(data.resolvers), Some(data.updateReport), Nil)
|
||||
case None => PluginData(globalPluginClasspath)
|
||||
}
|
||||
val baseDir = globalPlugin match {
|
||||
case Some(x) => x.base
|
||||
case _ => stagingDirectory
|
||||
}
|
||||
Load.loadPluginDefinition(baseDir, this, pluginData)
|
||||
val globalPlugins = Load.loadPluginDefinition(baseDir, this, pluginData)
|
||||
globalPlugins.detected
|
||||
}
|
||||
|
||||
lazy val detectedGlobalPlugins = globalPluginDefs.detected
|
||||
}
|
||||
|
||||
final class IncompatiblePluginsException(msg: String, cause: Throwable) extends Exception(msg, cause)
|
||||
|
|
|
|||
Loading…
Reference in New Issue