mirror of https://github.com/sbt/sbt.git
Remove OldPlugin
This commit is contained in:
parent
bf8c5d2135
commit
ffafdc2e03
|
|
@ -949,10 +949,6 @@ object Defaults extends BuildCommon {
|
|||
def sbtPluginExtra(m: ModuleID, sbtV: String, scalaV: String): ModuleID =
|
||||
m.extra(PomExtraDependencyAttributes.SbtVersionKey -> sbtV, PomExtraDependencyAttributes.ScalaVersionKey -> scalaV).copy(crossVersion = CrossVersion.Disabled)
|
||||
|
||||
@deprecated("Use PluginDiscovery.writeDescriptor.", "0.13.2")
|
||||
def writePluginsDescriptor(plugins: Set[String], dir: File): Seq[File] =
|
||||
PluginDiscovery.writeDescriptor(plugins.toSeq, dir, PluginDiscovery.Paths.Plugins).toList
|
||||
|
||||
def discoverSbtPluginNames: Initialize[Task[PluginDiscovery.DiscoveredNames]] = Def.task {
|
||||
if (sbtPlugin.value) PluginDiscovery.discoverSourceAll(compile.value) else PluginDiscovery.emptyDiscoveredNames
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ object BuiltinCommands {
|
|||
|
||||
def aboutPlugins(e: Extracted): String =
|
||||
{
|
||||
def list(b: BuildUnit) = b.plugins.detected.autoPlugins.map(_.value.label) ++ b.plugins.detected.plugins.names
|
||||
def list(b: BuildUnit) = b.plugins.detected.autoPlugins.map(_.value.label)
|
||||
val allPluginNames = e.structure.units.values.flatMap(u => list(u.unit)).toSeq.distinct
|
||||
if (allPluginNames.isEmpty) "" else allPluginNames.mkString("Available Plugins: ", ", ", "")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ sealed abstract class AddSettings
|
|||
object AddSettings {
|
||||
private[sbt] final class Sequence(val sequence: Seq[AddSettings]) extends AddSettings
|
||||
private[sbt] final object User extends AddSettings
|
||||
private[sbt] final class Plugins(val include: OldPlugin => Boolean) extends AddSettings
|
||||
private[sbt] final class AutoPlugins(val include: AutoPlugin => Boolean) extends AddSettings
|
||||
private[sbt] final class DefaultSbtFiles(val include: File => Boolean) extends AddSettings
|
||||
private[sbt] final class SbtFiles(val files: Seq[File]) extends AddSettings
|
||||
|
|
@ -30,14 +29,8 @@ object AddSettings {
|
|||
/** Settings specified in Build.scala `Project` constructors. */
|
||||
val buildScalaFiles: AddSettings = BuildScalaFiles
|
||||
|
||||
/** All plugins that aren't auto plugins. */
|
||||
val nonAutoPlugins: AddSettings = plugins(const(true))
|
||||
|
||||
/** Adds all settings from a plugin to a project. */
|
||||
val allPlugins: AddSettings = seq(autoPlugins, nonAutoPlugins)
|
||||
|
||||
/** Allows the plugins whose names match the `names` filter to automatically add settings to a project. */
|
||||
def plugins(include: OldPlugin => Boolean): AddSettings = new Plugins(include)
|
||||
val allPlugins: AddSettings = seq(autoPlugins)
|
||||
|
||||
/** Includes user settings in the project. */
|
||||
val userSettings: AddSettings = User
|
||||
|
|
@ -52,7 +45,7 @@ object AddSettings {
|
|||
def seq(autos: AddSettings*): AddSettings = new Sequence(autos)
|
||||
|
||||
/** The default inclusion of settings. */
|
||||
val allDefaults: AddSettings = seq(autoPlugins, buildScalaFiles, userSettings, nonAutoPlugins, defaultSbtFiles)
|
||||
val allDefaults: AddSettings = seq(autoPlugins, buildScalaFiles, userSettings, defaultSbtFiles)
|
||||
|
||||
/** Combines two automatic setting configurations. */
|
||||
def append(a: AddSettings, b: AddSettings): AddSettings = (a, b) match {
|
||||
|
|
|
|||
|
|
@ -123,9 +123,13 @@ 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[OldPlugin], 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) ++
|
||||
final class DetectedPlugins(val autoPlugins: Seq[DetectedAutoPlugin], val builds: DetectedModules[BuildDef]) {
|
||||
/**
|
||||
* Sequence of import expressions for the build definition.
|
||||
* This includes the names of the [[BuildDef]], and [[DetectedAutoPlugin]] modules,
|
||||
* but not the [[AutoPlugin]] modules.
|
||||
*/
|
||||
lazy val imports: Seq[String] = BuildUtil.getImports(builds.names) ++
|
||||
BuildUtil.importAllRoot(autoImports(autoPluginAutoImports)) ++
|
||||
BuildUtil.importAll(autoImports(topLevelAutoPluginAutoImports)) ++
|
||||
BuildUtil.importNamesRoot(autoPlugins.map(_.name).filter(nonTopLevelPlugin))
|
||||
|
|
@ -168,12 +172,6 @@ final class DetectedPlugins(val plugins: DetectedModules[OldPlugin], val autoPlu
|
|||
* @param detected Auto-detected modules in the build definition.
|
||||
*/
|
||||
final class LoadedPlugins(val base: File, val pluginData: PluginData, val loader: ClassLoader, val detected: DetectedPlugins) {
|
||||
@deprecated("Use the primary constructor.", "0.13.2")
|
||||
def this(base: File, pluginData: PluginData, loader: ClassLoader, plugins: Seq[OldPlugin], pluginNames: Seq[String]) =
|
||||
this(base, pluginData, loader,
|
||||
new DetectedPlugins(new DetectedModules(pluginNames zip plugins), Nil, new DetectedModules(Nil))
|
||||
)
|
||||
|
||||
def fullClasspath: Seq[Attributed[File]] = pluginData.classpath
|
||||
def classpath = data(fullClasspath)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,11 +216,10 @@ private[sbt] object Load {
|
|||
{
|
||||
((loadedBuild in GlobalScope :== loaded) +:
|
||||
transformProjectOnly(loaded.root, rootProject, injectSettings.global)) ++
|
||||
inScope(GlobalScope)(pluginGlobalSettings(loaded) ++ loaded.autos.globalSettings) ++
|
||||
inScope(GlobalScope)(loaded.autos.globalSettings) ++
|
||||
loaded.units.toSeq.flatMap {
|
||||
case (uri, build) =>
|
||||
val plugins = build.unit.plugins.detected.plugins.values
|
||||
val pluginBuildSettings = plugins.flatMap(_.buildSettings) ++ loaded.autos.buildSettings(uri)
|
||||
val pluginBuildSettings = loaded.autos.buildSettings(uri)
|
||||
val projectSettings = build.defined flatMap {
|
||||
case (id, project) =>
|
||||
val ref = ProjectRef(uri, id)
|
||||
|
|
@ -236,12 +235,6 @@ private[sbt] object Load {
|
|||
buildSettings ++ projectSettings
|
||||
}
|
||||
}
|
||||
@deprecated("Does not account for AutoPlugins and will be made private.", "0.13.2")
|
||||
def pluginGlobalSettings(loaded: LoadedBuild): Seq[Setting[_]] =
|
||||
loaded.units.toSeq flatMap {
|
||||
case (_, build) =>
|
||||
build.unit.plugins.detected.plugins.values flatMap { _.globalSettings }
|
||||
}
|
||||
|
||||
def transformProjectOnly(uri: URI, rootProject: URI => String, settings: Seq[Setting[_]]): Seq[Setting[_]] =
|
||||
Project.transform(Scope.resolveProject(uri, rootProject), settings)
|
||||
|
|
@ -671,11 +664,6 @@ private[sbt] object Load {
|
|||
val allSettings = {
|
||||
// TODO - This mechanism of applying settings could be off... It's in two places now...
|
||||
lazy val defaultSbtFiles = configurationSources(transformedProject.base)
|
||||
// Grabs the plugin settings for old-style sbt plugins.
|
||||
def pluginSettings(f: Plugins) = {
|
||||
val included = loadedPlugins.detected.plugins.values.filter(f.include) // don't apply the filter to AutoPlugins, only Plugins
|
||||
included.flatMap(p => p.projectSettings)
|
||||
}
|
||||
// Filter the AutoPlugin settings we included based on which ones are
|
||||
// intended in the AddSettings.AutoPlugins filter.
|
||||
def autoPluginSettings(f: AutoPlugins) =
|
||||
|
|
@ -693,7 +681,6 @@ private[sbt] object Load {
|
|||
case User => globalUserSettings.projectLoaded(loadedPlugins.loader)
|
||||
case sf: SbtFiles => settings(sf.files.map(f => IO.resolve(rawProject.base, f)))
|
||||
case sf: DefaultSbtFiles => settings(defaultSbtFiles.filter(sf.include))
|
||||
case p: Plugins => pluginSettings(p)
|
||||
case p: AutoPlugins => autoPluginSettings(p)
|
||||
case q: Sequence => (Seq.empty[Setting[_]] /: q.sequence) { (b, add) => b ++ expandSettings(add) }
|
||||
}
|
||||
|
|
@ -744,7 +731,7 @@ private[sbt] object Load {
|
|||
merge(fs.sortBy(_.getName).map(memoLoadSettingsFile))
|
||||
|
||||
// Finds all the build files associated with this project
|
||||
import AddSettings.{ User, SbtFiles, DefaultSbtFiles, Plugins, AutoPlugins, Sequence, BuildScalaFiles }
|
||||
import AddSettings.{ User, SbtFiles, DefaultSbtFiles, AutoPlugins, Sequence, BuildScalaFiles }
|
||||
def associatedFiles(auto: AddSettings): Seq[File] = auto match {
|
||||
case sf: SbtFiles => sf.files.map(f => IO.resolve(projectBase, f)).filterNot(_.isHidden)
|
||||
case sf: DefaultSbtFiles => defaultSbtFiles.filter(sf.include).filterNot(_.isHidden)
|
||||
|
|
@ -926,10 +913,7 @@ final case class LoadBuildConfiguration(
|
|||
globalPlugin: Option[GlobalPlugin],
|
||||
extraBuilds: Seq[URI],
|
||||
log: Logger) {
|
||||
lazy val (globalPluginClasspath, globalPluginLoader) = Load.pluginDefinitionLoader(this, Load.globalPluginClasspath(globalPlugin))
|
||||
lazy val globalPluginNames =
|
||||
if (globalPluginClasspath.isEmpty) Nil
|
||||
else PluginDiscovery.binarySourceModuleNames(classpath, loader, PluginDiscovery.Paths.Plugins, classOf[OldPlugin].getName)
|
||||
lazy val (globalPluginClasspath, _) = Load.pluginDefinitionLoader(this, Load.globalPluginClasspath(globalPlugin))
|
||||
|
||||
private[sbt] lazy val globalPluginDefs = {
|
||||
val pluginData = globalPlugin match {
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
package sbt
|
||||
package internal
|
||||
|
||||
import Def.Setting
|
||||
|
||||
@deprecated("Use AutoPlugin", "0.13.8")
|
||||
trait OldPlugin {
|
||||
/** 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
|
||||
}
|
||||
|
|
@ -20,15 +20,14 @@ object PluginDiscovery {
|
|||
*/
|
||||
object Paths {
|
||||
final val AutoPlugins = "sbt/sbt.autoplugins"
|
||||
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 [[BuildDef]]. */
|
||||
final class DiscoveredNames(val plugins: Seq[String], val autoPlugins: Seq[String], val builds: Seq[String]) {
|
||||
override def toString: String = s"""DiscoveredNames($plugins, $autoPlugins, $builds)"""
|
||||
/** Names of top-level modules that subclass sbt plugin-related classes: [[AutoPlugin]], and [[BuildDef]]. */
|
||||
final class DiscoveredNames(val autoPlugins: Seq[String], val builds: Seq[String]) {
|
||||
override def toString: String = s"""DiscoveredNames($autoPlugins, $builds)"""
|
||||
}
|
||||
|
||||
def emptyDiscoveredNames: DiscoveredNames = new DiscoveredNames(Nil, Nil, Nil)
|
||||
def emptyDiscoveredNames: DiscoveredNames = new DiscoveredNames(Nil, Nil)
|
||||
|
||||
/** Discovers and loads the sbt-plugin-related top-level modules from the classpath and source analysis in `data` and using the provided class `loader`. */
|
||||
def discoverAll(data: PluginData, loader: ClassLoader): DetectedPlugins =
|
||||
|
|
@ -48,7 +47,7 @@ object PluginDiscovery {
|
|||
case (name, value) =>
|
||||
DetectedAutoPlugin(name, value, sbt.Plugins.hasAutoImportGetter(value, loader))
|
||||
}
|
||||
new DetectedPlugins(discover[OldPlugin](Plugins), allAutoPlugins, discover[BuildDef](Builds))
|
||||
new DetectedPlugins(allAutoPlugins, discover[BuildDef](Builds))
|
||||
}
|
||||
|
||||
/** Discovers the sbt-plugin-related top-level modules from the provided source `analysis`. */
|
||||
|
|
@ -56,7 +55,7 @@ object PluginDiscovery {
|
|||
{
|
||||
def discover[T](implicit classTag: reflect.ClassTag[T]): Seq[String] =
|
||||
sourceModuleNames(analysis, classTag.runtimeClass.getName)
|
||||
new DiscoveredNames(discover[OldPlugin], discover[AutoPlugin], discover[BuildDef])
|
||||
new DiscoveredNames(discover[AutoPlugin], discover[BuildDef])
|
||||
}
|
||||
|
||||
// TODO: for 0.14.0, consider consolidating into a single file, which would make the classpath search 4x faster
|
||||
|
|
@ -65,8 +64,7 @@ object PluginDiscovery {
|
|||
{
|
||||
import Paths._
|
||||
val files =
|
||||
writeDescriptor(names.plugins, dir, Plugins) ::
|
||||
writeDescriptor(names.autoPlugins, dir, AutoPlugins) ::
|
||||
writeDescriptor(names.autoPlugins, dir, AutoPlugins) ::
|
||||
writeDescriptor(names.builds, dir, Builds) ::
|
||||
Nil
|
||||
files.flatMap(_.toList)
|
||||
|
|
|
|||
|
|
@ -83,11 +83,10 @@ object FakeState {
|
|||
)
|
||||
|
||||
val pluginData = PluginData(Nil, Nil, None, None, Nil)
|
||||
val detectedModules: DetectedModules[OldPlugin] = new DetectedModules(Nil)
|
||||
val builds: DetectedModules[BuildDef] = new DetectedModules[BuildDef](Nil)
|
||||
|
||||
val detectedAutoPlugins: Seq[DetectedAutoPlugin] = plugins.map(p => DetectedAutoPlugin(p.label, p, hasAutoImport = false))
|
||||
val detectedPlugins = new DetectedPlugins(detectedModules, detectedAutoPlugins, builds)
|
||||
val detectedPlugins = new DetectedPlugins(detectedAutoPlugins, builds)
|
||||
val loadedPlugins = new LoadedPlugins(base, pluginData, ClassLoader.getSystemClassLoader, detectedPlugins)
|
||||
val buildUnit = new BuildUnit(base.toURI, base, loadedDefinitions, loadedPlugins)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue