mirror of https://github.com/sbt/sbt.git
sbt.Build => sbt.internal.BuildDef
sbt.Load => sbt.internal.Load
This commit is contained in:
parent
83f35b18d3
commit
036e57c114
|
|
@ -9,6 +9,7 @@ import Def.{ displayFull, ScopedKey, ScopeLocal, Setting }
|
|||
import BuildPaths.outputDirectory
|
||||
import Scope.GlobalScope
|
||||
import BuildStreams.Streams
|
||||
import sbt.internal.{ BuildDef, Load }
|
||||
import sbt.io.Path._
|
||||
import sbt.internal.util.{ Attributed, AttributeEntry, AttributeKey, AttributeMap, Settings }
|
||||
import sbt.internal.util.Attributed.data
|
||||
|
|
@ -74,9 +75,9 @@ final class LoadedBuildUnit(val unit: BuildUnit, val defined: Map[String, Resolv
|
|||
* @param base The base directory of the build definition, typically `<build base>/project/`.
|
||||
* @param loader The ClassLoader containing all classes and plugins for the build definition project.
|
||||
* Note that this does not include classes for .sbt files.
|
||||
* @param builds The list of [[Build]]s for the build unit.
|
||||
* In addition to auto-discovered [[Build]]s, this includes any auto-generated default [[Build]]s.
|
||||
* @param projects The list of all [[Project]]s from all [[Build]]s.
|
||||
* @param builds The list of [[BuildDef]]s for the build unit.
|
||||
* In addition to auto-discovered [[BuildDef]]s, this includes any auto-generated default [[BuildDef]]s.
|
||||
* @param projects The list of all [[Project]]s from all [[BuildDef]]s.
|
||||
* These projects have not yet been resolved, but they have had auto-plugins applied.
|
||||
* In particular, each [[Project]]'s `autoPlugins` field is populated according to their configured `plugins`
|
||||
* and their `settings` and `configurations` updated as appropriate.
|
||||
|
|
@ -86,14 +87,14 @@ final class LoadedDefinitions(
|
|||
val base: File,
|
||||
val target: Seq[File],
|
||||
val loader: ClassLoader,
|
||||
val builds: Seq[Build],
|
||||
val builds: Seq[BuildDef],
|
||||
val projects: Seq[Project],
|
||||
val buildNames: Seq[String],
|
||||
val dslDefinitions: DefinedSbtValues) {
|
||||
def this(base: File,
|
||||
target: Seq[File],
|
||||
loader: ClassLoader,
|
||||
builds: Seq[Build],
|
||||
builds: Seq[BuildDef],
|
||||
projects: Seq[Project],
|
||||
buildNames: Seq[String]) = this(base, target, loader, builds, projects, buildNames, DefinedSbtValues.empty)
|
||||
}
|
||||
|
|
@ -122,7 +123,7 @@ case class DetectedAutoPlugin(name: String, value: AutoPlugin, hasAutoImport: Bo
|
|||
*
|
||||
* @param builds The [[Build]]s detected in the build definition. This does not include the default [[Build]] that sbt creates if none is defined.
|
||||
*/
|
||||
final class DetectedPlugins(val plugins: DetectedModules[Plugin], val autoPlugins: Seq[DetectedAutoPlugin], val builds: DetectedModules[Build]) {
|
||||
final class DetectedPlugins(val plugins: DetectedModules[Plugin], val autoPlugins: Seq[DetectedAutoPlugin], val builds: DetectedModules[BuildDef]) {
|
||||
/** Sequence of import expressions for the build definition. This includes the names of the [[Plugin]], [[Build]], and [[AutoImport]] modules, but not the [[AutoPlugin]] modules. */
|
||||
lazy val imports: Seq[String] = BuildUtil.getImports(plugins.names ++ builds.names) ++
|
||||
BuildUtil.importAllRoot(autoImports(autoPluginAutoImports)) ++
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package sbt
|
||||
|
||||
import sbt.internal.util.{ Relation, Settings, Dag }
|
||||
import sbt.internal.Load
|
||||
|
||||
import java.net.URI
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package sbt
|
||||
|
||||
import sbt.internal.Load
|
||||
import sbt.internal.util.{ ErrorHandling, RMap, Show, Signals, Types }
|
||||
import sbt.util.Logger
|
||||
import sbt.librarymanagement.{ Resolver, UpdateReport }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package sbt
|
||||
|
||||
import sbt.internal.Load
|
||||
import Project._
|
||||
import Scope.GlobalScope
|
||||
import Def.{ ScopedKey, Setting }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package sbt
|
|||
import sbt.librarymanagement.{ Configuration, Configurations, ModuleID, Resolver, SbtArtifacts, UpdateReport }
|
||||
import sbt.internal.util.Attributed
|
||||
|
||||
import Load.{ BuildStructure => _, _ }
|
||||
import sbt.internal.{ Load, LoadBuildConfiguration }
|
||||
import Def.{ ScopedKey, Setting }
|
||||
import Scoped._
|
||||
import Keys._
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package sbt
|
||||
|
||||
import sbt.internal.Load
|
||||
import sbt.internal.util.Attributed
|
||||
import sbt.util.{ Level, Logger }
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package sbt
|
||||
|
||||
import sbt.internal.Load
|
||||
import sbt.internal.util.{ AttributeKey, AttributeMap, complete, ConsoleOut, GlobalLogging, LineRange, MainLogging, SimpleReader, Types }
|
||||
import sbt.util.{ Level, Logger }
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package sbt
|
||||
|
||||
import Def.Setting
|
||||
|
||||
// TODO 0.14.0: decide if Plugin should be deprecated in favor of AutoPlugin
|
||||
trait Plugin {
|
||||
@deprecated("Override projectSettings or buildSettings instead.", "0.12.0")
|
||||
def settings: Seq[Setting[_]] = Nil
|
||||
|
||||
/** Settings to be appended to all projects in a build. */
|
||||
def projectSettings: Seq[Setting[_]] = Nil
|
||||
|
||||
/** Settings to be appended at the build scope. */
|
||||
def buildSettings: Seq[Setting[_]] = Nil
|
||||
|
||||
/** Settings to be appended at the global scope. */
|
||||
def globalSettings: Seq[Setting[_]] = Nil
|
||||
}
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package sbt
|
||||
|
||||
import sbt.internal.util.Attributed
|
||||
|
||||
import sbt.internal.{ BuildDef, IncompatiblePluginsException }
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import Attributed.data
|
||||
import Build.analyzed
|
||||
import sbt.internal.BuildDef.analyzed
|
||||
import xsbt.api.{ Discovered, Discovery }
|
||||
import xsbti.compile.CompileAnalysis
|
||||
import sbt.internal.inc.ModuleUtilities
|
||||
|
|
@ -22,7 +22,7 @@ object PluginDiscovery {
|
|||
final val Plugins = "sbt/sbt.plugins"
|
||||
final val Builds = "sbt/sbt.builds"
|
||||
}
|
||||
/** Names of top-level modules that subclass sbt plugin-related classes: [[Plugin]], [[AutoPlugin]], and [[Build]]. */
|
||||
/** Names of top-level modules that subclass sbt plugin-related classes: [[Plugin]], [[AutoPlugin]], and [[BuildDef]]. */
|
||||
final class DiscoveredNames(val plugins: Seq[String], val autoPlugins: Seq[String], val builds: Seq[String])
|
||||
|
||||
def emptyDiscoveredNames: DiscoveredNames = new DiscoveredNames(Nil, Nil, Nil)
|
||||
|
|
@ -45,7 +45,7 @@ object PluginDiscovery {
|
|||
case (name, value) =>
|
||||
DetectedAutoPlugin(name, value, sbt.Plugins.hasAutoImportGetter(value, loader))
|
||||
}
|
||||
new DetectedPlugins(discover[Plugin](Plugins), allAutoPlugins, discover[Build](Builds))
|
||||
new DetectedPlugins(discover[Plugin](Plugins), allAutoPlugins, discover[BuildDef](Builds))
|
||||
}
|
||||
|
||||
/** Discovers the sbt-plugin-related top-level modules from the provided source `analysis`. */
|
||||
|
|
@ -53,7 +53,7 @@ object PluginDiscovery {
|
|||
{
|
||||
def discover[T](implicit classTag: reflect.ClassTag[T]): Seq[String] =
|
||||
sourceModuleNames(analysis, classTag.runtimeClass.getName)
|
||||
new DiscoveredNames(discover[Plugin], discover[AutoPlugin], discover[Build])
|
||||
new DiscoveredNames(discover[Plugin], discover[AutoPlugin], discover[BuildDef])
|
||||
}
|
||||
|
||||
// TODO: for 0.14.0, consider consolidating into a single file, which would make the classpath search 4x faster
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import Project.{ Initialize => _, Setting => _, _ }
|
|||
import Keys.{ appConfiguration, stateBuildStructure, commands, configuration, historyPath, projectCommand, sessionSettings, shellPrompt, thisProject, thisProjectRef, watch }
|
||||
import Scope.{ GlobalScope, ThisScope }
|
||||
import Def.{ Flattened, Initialize, ScopedKey, Setting }
|
||||
import sbt.internal.Load
|
||||
import sbt.internal.util.Types.{ const, idFun }
|
||||
import sbt.internal.util.complete.DefaultParsers
|
||||
import sbt.librarymanagement.Configuration
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package sbt
|
||||
|
||||
import sbt.internal.Load
|
||||
import sbt.internal.util.complete
|
||||
|
||||
import ProjectNavigation._
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
package sbt
|
||||
|
||||
import sbt.internal.BuildLoader
|
||||
import sbt.internal.librarymanagement.StringUtilities
|
||||
|
||||
import sbt.io.{ Hash, IO }
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ package sbt
|
|||
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
import BuildLoader.ResolveInfo
|
||||
import sbt.internal.BuildLoader.ResolveInfo
|
||||
import Def.{ ScopedKey, Setting }
|
||||
|
||||
object RetrieveUnit {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package sbt
|
||||
|
||||
import sbt.internal.Load
|
||||
import sbt.internal.util.{ AttributeKey, Dag, Types }
|
||||
|
||||
import sbt.librarymanagement.Configuration
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package sbt
|
||||
|
||||
import sbt.internal.Load
|
||||
import sbt.librarymanagement.Configurations
|
||||
|
||||
import sbt.util.Level
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package sbt
|
||||
|
||||
import sbt.internal.Load
|
||||
import sbt.internal.util.{ AttributeKey, complete, Relation, Settings, Show, Types, Util }
|
||||
|
||||
import sbt.librarymanagement.Configuration
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright 2011 Mark Harrah
|
||||
*/
|
||||
package sbt
|
||||
package internal
|
||||
|
||||
import java.io.File
|
||||
import Keys.{ name, organization, thisProject, autoGeneratedProject }
|
||||
|
|
@ -10,8 +11,7 @@ import sbt.io.Hash
|
|||
import sbt.internal.util.Attributed
|
||||
import sbt.internal.inc.ReflectUtilities
|
||||
|
||||
// name is more like BuildDefinition, but that is too long
|
||||
trait Build {
|
||||
private[sbt] trait BuildDef {
|
||||
def projectDefinitions(baseDirectory: File): Seq[Project] = projects
|
||||
def projects: Seq[Project] = ReflectUtilities.allVals[Project](this).values.toSeq
|
||||
// TODO: Should we grab the build core setting shere or in a plugin?
|
||||
|
|
@ -23,31 +23,16 @@ trait Build {
|
|||
*/
|
||||
def rootProject: Option[Project] = None
|
||||
}
|
||||
// TODO 0.14.0: decide if Plugin should be deprecated in favor of AutoPlugin
|
||||
trait Plugin {
|
||||
@deprecated("Override projectSettings or buildSettings instead.", "0.12.0")
|
||||
def settings: Seq[Setting[_]] = Nil
|
||||
|
||||
/** Settings to be appended to all projects in a build. */
|
||||
def projectSettings: Seq[Setting[_]] = Nil
|
||||
|
||||
/** Settings to be appended at the build scope. */
|
||||
def buildSettings: Seq[Setting[_]] = Nil
|
||||
|
||||
/** Settings to be appended at the global scope. */
|
||||
def globalSettings: Seq[Setting[_]] = Nil
|
||||
}
|
||||
|
||||
object Build {
|
||||
val defaultEmpty: Build = new Build { override def projects = Nil }
|
||||
val default: Build = new Build { override def projectDefinitions(base: File) = defaultProject(defaultID(base), base) :: Nil }
|
||||
def defaultAggregated(id: String, aggregate: Seq[ProjectRef]): Build = new Build {
|
||||
private[sbt] object BuildDef {
|
||||
val defaultEmpty: BuildDef = new BuildDef { override def projects = Nil }
|
||||
val default: BuildDef = new BuildDef { override def projectDefinitions(base: File) = defaultProject(defaultID(base), base) :: Nil }
|
||||
def defaultAggregated(id: String, aggregate: Seq[ProjectRef]): BuildDef = new BuildDef {
|
||||
override def projectDefinitions(base: File) = defaultAggregatedProject(id, base, aggregate) :: Nil
|
||||
}
|
||||
|
||||
def defaultID(base: File, prefix: String = "default"): String = prefix + "-" + Hash.trimHashString(base.getAbsolutePath, 6)
|
||||
@deprecated("Explicitly specify the ID", "0.13.0")
|
||||
def defaultProject(base: File): Project = defaultProject(defaultID(base), base)
|
||||
|
||||
def defaultProject(id: String, base: File): Project = Project(id, base).settings(defaultProjectSettings)
|
||||
def defaultAggregatedProject(id: String, base: File, agg: Seq[ProjectRef]): Project =
|
||||
defaultProject(id, base).aggregate(agg: _*)
|
||||
|
|
@ -66,8 +51,5 @@ object Build {
|
|||
},
|
||||
autoGeneratedProject := true
|
||||
)
|
||||
|
||||
@deprecated("Use Attributed.data", "0.13.0")
|
||||
def data[T](in: Seq[Attributed[T]]): Seq[T] = Attributed.data(in)
|
||||
def analyzed(in: Seq[Attributed[_]]): Seq[xsbti.compile.CompileAnalysis] = in.flatMap { _.metadata.get(Keys.analysis) }
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright 2011 Mark Harrah
|
||||
*/
|
||||
package sbt
|
||||
package internal
|
||||
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
* Copyright 2011 Mark Harrah
|
||||
*/
|
||||
package sbt
|
||||
package internal
|
||||
|
||||
import sbt.internal.util.{ Settings, Show, ~> }
|
||||
import sbt.librarymanagement.{ Configuration, Configurations, Resolver }
|
||||
|
|
@ -31,7 +32,7 @@ import sbt.internal.io.Alternatives
|
|||
import sbt.util.Logger
|
||||
import xsbti.compile.Compilers
|
||||
|
||||
object Load {
|
||||
private[sbt] object Load {
|
||||
// note that there is State passed in but not pulled out
|
||||
def defaultLoad(state: State, baseDirectory: File, log: Logger, isPlugin: Boolean = false, topLevelExtras: List[URI] = Nil): (() => Eval, sbt.BuildStructure) =
|
||||
{
|
||||
|
|
@ -45,7 +46,7 @@ object Load {
|
|||
definesClass.clear()
|
||||
result
|
||||
}
|
||||
def defaultPreGlobal(state: State, baseDirectory: File, definesClass: DefinesClass, globalBase: File, log: Logger): sbt.LoadBuildConfiguration =
|
||||
def defaultPreGlobal(state: State, baseDirectory: File, definesClass: DefinesClass, globalBase: File, log: Logger): LoadBuildConfiguration =
|
||||
{
|
||||
val provider = state.configuration.provider
|
||||
val scalaProvider = provider.scalaProvider
|
||||
|
|
@ -64,7 +65,7 @@ object Load {
|
|||
val initialID = baseDirectory.getName
|
||||
val pluginMgmt = PluginManagement(loader)
|
||||
val inject = InjectSettings(injectGlobal(state), Nil, const(Nil))
|
||||
new sbt.LoadBuildConfiguration(stagingDirectory, classpath, loader, compilers, evalPluginDef, definesClass, delegates,
|
||||
new LoadBuildConfiguration(stagingDirectory, classpath, loader, compilers, evalPluginDef, definesClass, delegates,
|
||||
EvaluateTask.injectStreams, pluginMgmt, inject, None, Nil, log)
|
||||
}
|
||||
private def bootIvyHome(app: xsbti.AppConfiguration): Option[File] =
|
||||
|
|
@ -74,7 +75,7 @@ object Load {
|
|||
(appConfiguration in GlobalScope :== state.configuration) +:
|
||||
LogManager.settingsLogger(state) +:
|
||||
EvaluateTask.injectSettings
|
||||
def defaultWithGlobal(state: State, base: File, rawConfig: sbt.LoadBuildConfiguration, globalBase: File, log: Logger): sbt.LoadBuildConfiguration =
|
||||
def defaultWithGlobal(state: State, base: File, rawConfig: LoadBuildConfiguration, globalBase: File, log: Logger): LoadBuildConfiguration =
|
||||
{
|
||||
val globalPluginsDir = getGlobalPluginsDirectory(state, globalBase)
|
||||
val withGlobal = loadGlobal(state, base, globalPluginsDir, rawConfig)
|
||||
|
|
@ -82,13 +83,13 @@ object Load {
|
|||
loadGlobalSettings(base, globalBase, globalSettings, withGlobal)
|
||||
}
|
||||
|
||||
def loadGlobalSettings(base: File, globalBase: File, files: Seq[File], config: sbt.LoadBuildConfiguration): sbt.LoadBuildConfiguration =
|
||||
def loadGlobalSettings(base: File, globalBase: File, files: Seq[File], config: LoadBuildConfiguration): LoadBuildConfiguration =
|
||||
{
|
||||
val compiled: ClassLoader => Seq[Setting[_]] =
|
||||
if (files.isEmpty || base == globalBase) const(Nil) else buildGlobalSettings(globalBase, files, config)
|
||||
config.copy(injectSettings = config.injectSettings.copy(projectLoaded = compiled))
|
||||
}
|
||||
def buildGlobalSettings(base: File, files: Seq[File], config: sbt.LoadBuildConfiguration): ClassLoader => Seq[Setting[_]] =
|
||||
def buildGlobalSettings(base: File, files: Seq[File], config: LoadBuildConfiguration): ClassLoader => Seq[Setting[_]] =
|
||||
{
|
||||
val eval = mkEval(data(config.globalPluginClasspath), base, defaultEvalOptions)
|
||||
|
||||
|
|
@ -103,7 +104,7 @@ object Load {
|
|||
loaded.settings
|
||||
}
|
||||
}
|
||||
def loadGlobal(state: State, base: File, global: File, config: sbt.LoadBuildConfiguration): sbt.LoadBuildConfiguration =
|
||||
def loadGlobal(state: State, base: File, global: File, config: LoadBuildConfiguration): LoadBuildConfiguration =
|
||||
if (base != global && global.exists) {
|
||||
val gp = GlobalPlugin.load(global, state, config)
|
||||
config.copy(globalPlugin = Some(gp))
|
||||
|
|
@ -144,7 +145,7 @@ object Load {
|
|||
// 6) Load all configurations using build definitions and plugins (their classpaths and loaded instances).
|
||||
// 7) Combine settings from projects, plugins, and configurations
|
||||
// 8) Evaluate settings
|
||||
def apply(rootBase: File, s: State, config: sbt.LoadBuildConfiguration): (() => Eval, sbt.BuildStructure) =
|
||||
def apply(rootBase: File, s: State, config: LoadBuildConfiguration): (() => Eval, sbt.BuildStructure) =
|
||||
{
|
||||
// load, which includes some resolution, but can't fill in project IDs yet, so follow with full resolution
|
||||
val loaded = resolveProjects(load(rootBase, s, config))
|
||||
|
|
@ -292,9 +293,9 @@ object Load {
|
|||
if (srcs.isEmpty) const(LoadedSbtFile.empty)
|
||||
else EvaluateConfigurations(eval(), srcs, imports)
|
||||
|
||||
def load(file: File, s: State, config: sbt.LoadBuildConfiguration): sbt.PartBuild =
|
||||
def load(file: File, s: State, config: LoadBuildConfiguration): sbt.PartBuild =
|
||||
load(file, builtinLoader(s, config.copy(pluginManagement = config.pluginManagement.shift, extraBuilds = Nil)), config.extraBuilds.toList)
|
||||
def builtinLoader(s: State, config: sbt.LoadBuildConfiguration): BuildLoader =
|
||||
def builtinLoader(s: State, config: LoadBuildConfiguration): BuildLoader =
|
||||
{
|
||||
val fail = (uri: URI) => sys.error("Invalid build URI (no handler available): " + uri)
|
||||
val resolver = (info: BuildLoader.ResolveInfo) => RetrieveUnit(info)
|
||||
|
|
@ -443,7 +444,7 @@ object Load {
|
|||
def noProject(uri: URI, id: String) = sys.error(s"No project '$id' defined in '$uri'.")
|
||||
def noConfiguration(uri: URI, id: String, conf: String) = sys.error(s"No configuration '$conf' defined in project '$id' in '$uri'")
|
||||
|
||||
def loadUnit(uri: URI, localBase: File, s: State, config: sbt.LoadBuildConfiguration): sbt.BuildUnit =
|
||||
def loadUnit(uri: URI, localBase: File, s: State, config: LoadBuildConfiguration): sbt.BuildUnit =
|
||||
{
|
||||
val normBase = localBase.getCanonicalFile
|
||||
val defDir = projectStandard(normBase)
|
||||
|
|
@ -470,12 +471,12 @@ object Load {
|
|||
val hasRoot = loadedProjectsRaw.projects.exists(_.base == normBase) || defsScala.exists(_.rootProject.isDefined)
|
||||
val (loadedProjects, defaultBuildIfNone, keepClassFiles) =
|
||||
if (hasRoot)
|
||||
(loadedProjectsRaw.projects, Build.defaultEmpty, loadedProjectsRaw.generatedConfigClassFiles)
|
||||
(loadedProjectsRaw.projects, BuildDef.defaultEmpty, loadedProjectsRaw.generatedConfigClassFiles)
|
||||
else {
|
||||
val existingIDs = loadedProjectsRaw.projects.map(_.id)
|
||||
val refs = existingIDs.map(id => ProjectRef(uri, id))
|
||||
val defaultID = autoID(normBase, config.pluginManagement.context, existingIDs)
|
||||
val b = Build.defaultAggregated(defaultID, refs)
|
||||
val b = BuildDef.defaultAggregated(defaultID, refs)
|
||||
val defaultProjects = loadProjects(projectsFromBuild(b, normBase), false)
|
||||
(defaultProjects.projects ++ loadedProjectsRaw.projects, b, defaultProjects.generatedConfigClassFiles ++ loadedProjectsRaw.generatedConfigClassFiles)
|
||||
}
|
||||
|
|
@ -500,19 +501,19 @@ object Load {
|
|||
case Left(msg) => sys.error(autoIDError(f, msg))
|
||||
}
|
||||
def nthParentName(f: File, i: Int): String =
|
||||
if (f eq null) Build.defaultID(localBase) else if (i <= 0) normalizeID(f) else nthParentName(f.getParentFile, i - 1)
|
||||
if (f eq null) BuildDef.defaultID(localBase) else if (i <= 0) normalizeID(f) else nthParentName(f.getParentFile, i - 1)
|
||||
val pluginDepth = context.pluginProjectDepth
|
||||
val postfix = "-build" * pluginDepth
|
||||
val idBase = if (context.globalPluginProject) "global-plugins" else nthParentName(localBase, pluginDepth)
|
||||
val tryID = idBase + postfix
|
||||
if (existingIDs.contains(tryID)) Build.defaultID(localBase) else tryID
|
||||
if (existingIDs.contains(tryID)) BuildDef.defaultID(localBase) else tryID
|
||||
}
|
||||
|
||||
private[this] def autoIDError(base: File, reason: String): String =
|
||||
"Could not derive root project ID from directory " + base.getAbsolutePath + ":\n" +
|
||||
reason + "\nRename the directory or explicitly define a root project."
|
||||
|
||||
private[this] def projectsFromBuild(b: Build, base: File): Seq[Project] =
|
||||
private[this] def projectsFromBuild(b: BuildDef, base: File): Seq[Project] =
|
||||
b.projectDefinitions(base).map(resolveBase(base))
|
||||
|
||||
// Lame hackery to keep track of our state.
|
||||
|
|
@ -605,8 +606,8 @@ object Load {
|
|||
val existingIds = otherProjects.projects map (_.id)
|
||||
val refs = existingIds map (id => ProjectRef(buildUri, id))
|
||||
val defaultID = autoID(buildBase, context, existingIds)
|
||||
val root0 = if (discovered.isEmpty || java.lang.Boolean.getBoolean("sbt.root.ivyplugin")) Build.defaultAggregatedProject(defaultID, buildBase, refs)
|
||||
else Build.generatedRootWithoutIvyPlugin(defaultID, buildBase, refs)
|
||||
val root0 = if (discovered.isEmpty || java.lang.Boolean.getBoolean("sbt.root.ivyplugin")) BuildDef.defaultAggregatedProject(defaultID, buildBase, refs)
|
||||
else BuildDef.generatedRootWithoutIvyPlugin(defaultID, buildBase, refs)
|
||||
val root = finalizeProject(root0, files)
|
||||
val result = root +: (acc ++ otherProjects.projects)
|
||||
log.debug(s"[Loading] Done in ${buildBase}, returning: ${result.map(_.id).mkString("(", ", ", ")")}")
|
||||
|
|
@ -785,17 +786,17 @@ object Load {
|
|||
cp filter { f => !files.contains(f.data) }
|
||||
}
|
||||
|
||||
def enableSbtPlugin(config: sbt.LoadBuildConfiguration): sbt.LoadBuildConfiguration =
|
||||
def enableSbtPlugin(config: LoadBuildConfiguration): LoadBuildConfiguration =
|
||||
config.copy(injectSettings = config.injectSettings.copy(
|
||||
global = autoPluginSettings ++ config.injectSettings.global,
|
||||
project = config.pluginManagement.inject ++ config.injectSettings.project
|
||||
))
|
||||
def activateGlobalPlugin(config: sbt.LoadBuildConfiguration): sbt.LoadBuildConfiguration =
|
||||
def activateGlobalPlugin(config: LoadBuildConfiguration): LoadBuildConfiguration =
|
||||
config.globalPlugin match {
|
||||
case Some(gp) => config.copy(injectSettings = config.injectSettings.copy(project = gp.inject))
|
||||
case None => config
|
||||
}
|
||||
def plugins(dir: File, s: State, config: sbt.LoadBuildConfiguration): sbt.LoadedPlugins =
|
||||
def plugins(dir: File, s: State, config: LoadBuildConfiguration): sbt.LoadedPlugins =
|
||||
if (hasDefinition(dir))
|
||||
buildPlugins(dir, s, enableSbtPlugin(activateGlobalPlugin(config)))
|
||||
else
|
||||
|
|
@ -806,21 +807,21 @@ object Load {
|
|||
import Path._
|
||||
(dir * -GlobFilter(DefaultTargetName)).get.nonEmpty
|
||||
}
|
||||
def noPlugins(dir: File, config: sbt.LoadBuildConfiguration): sbt.LoadedPlugins =
|
||||
def noPlugins(dir: File, config: LoadBuildConfiguration): sbt.LoadedPlugins =
|
||||
loadPluginDefinition(dir, config, PluginData(config.globalPluginClasspath, None, None))
|
||||
def buildPlugins(dir: File, s: State, config: sbt.LoadBuildConfiguration): sbt.LoadedPlugins =
|
||||
def buildPlugins(dir: File, s: State, config: LoadBuildConfiguration): sbt.LoadedPlugins =
|
||||
loadPluginDefinition(dir, config, buildPluginDefinition(dir, s, config))
|
||||
|
||||
def loadPluginDefinition(dir: File, config: sbt.LoadBuildConfiguration, pluginData: PluginData): sbt.LoadedPlugins =
|
||||
def loadPluginDefinition(dir: File, config: LoadBuildConfiguration, pluginData: PluginData): sbt.LoadedPlugins =
|
||||
{
|
||||
val (definitionClasspath, pluginLoader) = pluginDefinitionLoader(config, pluginData)
|
||||
loadPlugins(dir, pluginData.copy(dependencyClasspath = definitionClasspath), pluginLoader)
|
||||
}
|
||||
def pluginDefinitionLoader(config: sbt.LoadBuildConfiguration, dependencyClasspath: Seq[Attributed[File]]): (Seq[Attributed[File]], ClassLoader) =
|
||||
def pluginDefinitionLoader(config: LoadBuildConfiguration, dependencyClasspath: Seq[Attributed[File]]): (Seq[Attributed[File]], ClassLoader) =
|
||||
pluginDefinitionLoader(config, dependencyClasspath, Nil)
|
||||
def pluginDefinitionLoader(config: sbt.LoadBuildConfiguration, pluginData: PluginData): (Seq[Attributed[File]], ClassLoader) =
|
||||
def pluginDefinitionLoader(config: LoadBuildConfiguration, pluginData: PluginData): (Seq[Attributed[File]], ClassLoader) =
|
||||
pluginDefinitionLoader(config, pluginData.dependencyClasspath, pluginData.definitionClasspath)
|
||||
def pluginDefinitionLoader(config: sbt.LoadBuildConfiguration, depcp: Seq[Attributed[File]], defcp: Seq[Attributed[File]]): (Seq[Attributed[File]], ClassLoader) =
|
||||
def pluginDefinitionLoader(config: LoadBuildConfiguration, depcp: Seq[Attributed[File]], defcp: Seq[Attributed[File]]): (Seq[Attributed[File]], ClassLoader) =
|
||||
{
|
||||
val definitionClasspath =
|
||||
if (depcp.isEmpty)
|
||||
|
|
@ -841,20 +842,20 @@ object Load {
|
|||
}
|
||||
(definitionClasspath, pluginLoader)
|
||||
}
|
||||
def buildPluginDefinition(dir: File, s: State, config: sbt.LoadBuildConfiguration): PluginData =
|
||||
def buildPluginDefinition(dir: File, s: State, config: LoadBuildConfiguration): PluginData =
|
||||
{
|
||||
val (eval, pluginDef) = apply(dir, s, config)
|
||||
val pluginState = Project.setProject(Load.initialSession(pluginDef, eval), pluginDef, s)
|
||||
config.evalPluginDef(Project.structure(pluginState), pluginState)
|
||||
}
|
||||
|
||||
@deprecated("Use ModuleUtilities.getCheckedObjects[Build].", "0.13.2")
|
||||
def loadDefinitions(loader: ClassLoader, defs: Seq[String]): Seq[Build] =
|
||||
@deprecated("Use ModuleUtilities.getCheckedObjects[BuildDef].", "0.13.2")
|
||||
def loadDefinitions(loader: ClassLoader, defs: Seq[String]): Seq[BuildDef] =
|
||||
defs map { definition => loadDefinition(loader, definition) }
|
||||
|
||||
@deprecated("Use ModuleUtilities.getCheckedObject[Build].", "0.13.2")
|
||||
def loadDefinition(loader: ClassLoader, definition: String): Build =
|
||||
ModuleUtilities.getObject(definition, loader).asInstanceOf[Build]
|
||||
@deprecated("Use ModuleUtilities.getCheckedObject[BuildDef].", "0.13.2")
|
||||
def loadDefinition(loader: ClassLoader, definition: String): BuildDef =
|
||||
ModuleUtilities.getObject(definition, loader).asInstanceOf[BuildDef]
|
||||
|
||||
def loadPlugins(dir: File, data: PluginData, loader: ClassLoader): sbt.LoadedPlugins =
|
||||
new sbt.LoadedPlugins(dir, data, loader, PluginDiscovery.discoverAll(data, loader))
|
||||
|
|
@ -883,7 +884,7 @@ object Load {
|
|||
def findPlugins(analysis: Analysis): Seq[String] = discover(analysis, "sbt.Plugin")
|
||||
|
||||
@deprecated("No longer used.", "0.13.2")
|
||||
def findDefinitions(analysis: Analysis): Seq[String] = discover(analysis, "sbt.Build")
|
||||
def findDefinitions(analysis: Analysis): Seq[String] = discover(analysis, "sbt.internal.BuildDef")
|
||||
|
||||
@deprecated("Use PluginDiscovery.sourceModuleNames", "0.13.2")
|
||||
def discover(analysis: Analysis, subclasses: String*): Seq[String] =
|
||||
|
|
@ -928,37 +929,9 @@ object Load {
|
|||
|
||||
def referenced[PR <: ProjectReference](definitions: Seq[ProjectDefinition[PR]]): Seq[PR] = definitions flatMap { _.referenced }
|
||||
|
||||
@deprecated("LoadedBuildUnit is now top-level", "0.13.0")
|
||||
type LoadedBuildUnit = sbt.LoadedBuildUnit
|
||||
|
||||
@deprecated("BuildStructure is now top-level", "0.13.0")
|
||||
type BuildStructure = sbt.BuildStructure
|
||||
|
||||
@deprecated("StructureIndex is now top-level", "0.13.0")
|
||||
type StructureIndex = sbt.StructureIndex
|
||||
|
||||
@deprecated("LoadBuildConfiguration is now top-level", "0.13.0")
|
||||
type LoadBuildConfiguration = sbt.LoadBuildConfiguration
|
||||
@deprecated("LoadBuildConfiguration is now top-level", "0.13.0")
|
||||
val LoadBuildConfiguration = sbt.LoadBuildConfiguration
|
||||
|
||||
final class EvaluatedConfigurations(val eval: Eval, val settings: Seq[Setting[_]])
|
||||
final case class InjectSettings(global: Seq[Setting[_]], project: Seq[Setting[_]], projectLoaded: ClassLoader => Seq[Setting[_]])
|
||||
|
||||
@deprecated("LoadedDefinitions is now top-level", "0.13.0")
|
||||
type LoadedDefinitions = sbt.LoadedDefinitions
|
||||
@deprecated("LoadedPlugins is now top-level", "0.13.0")
|
||||
type LoadedPlugins = sbt.LoadedPlugins
|
||||
@deprecated("BuildUnit is now top-level", "0.13.0")
|
||||
type BuildUnit = sbt.BuildUnit
|
||||
@deprecated("LoadedBuild is now top-level", "0.13.0")
|
||||
type LoadedBuild = sbt.LoadedBuild
|
||||
@deprecated("PartBuild is now top-level", "0.13.0")
|
||||
type PartBuild = sbt.PartBuild
|
||||
@deprecated("BuildUnitBase is now top-level", "0.13.0")
|
||||
type BuildUnitBase = sbt.BuildUnitBase
|
||||
@deprecated("PartBuildUnit is now top-level", "0.13.0")
|
||||
type PartBuildUnit = sbt.PartBuildUnit
|
||||
@deprecated("Use BuildUtil.apply", "0.13.0")
|
||||
def buildUtil(root: URI, units: Map[URI, sbt.LoadedBuildUnit], keyIndex: KeyIndex, data: Settings[Scope]): BuildUtil[ResolvedProject] = BuildUtil(root, units, keyIndex, data)
|
||||
}
|
||||
Loading…
Reference in New Issue