mirror of https://github.com/sbt/sbt.git
Add SbtPlugin
Fixes #3538 This brings in `sbt.ScriptedPlugin` as `sbt.plugins.ScriptedPlugin` into sbt mothership. In addition, `sbt.plugins.SbtPlugin` is added that enables the scripted plugin and `sbtPlugin := true`. This allows plugin authors to bring in scripted plugin by writing: ```scala lazy val root = (project in file(".")) .enablePlugins(SbtPlugin) ```
This commit is contained in:
parent
655c2ac5d1
commit
08eaba9107
11
build.sbt
11
build.sbt
|
|
@ -272,11 +272,18 @@ lazy val scriptedSbtProj = (project in scriptedPath / "sbt")
|
|||
.configure(addSbtIO, addSbtUtilLogging, addSbtCompilerInterface, addSbtUtilScripted, addSbtLmCore)
|
||||
|
||||
lazy val scriptedPluginProj = (project in scriptedPath / "plugin")
|
||||
.dependsOn(sbtProj)
|
||||
.dependsOn(mainProj)
|
||||
.settings(
|
||||
baseSettings,
|
||||
name := "Scripted Plugin",
|
||||
mimaSettings,
|
||||
mimaBinaryIssueFilters ++= Seq(
|
||||
// scripted plugin has moved into sbt mothership as sbt.plugins.ScriptedPlugin.
|
||||
// sbt.ScriptedPlugin is still here for bincomat.
|
||||
exclude[DirectMissingMethodProblem]("sbt.ScriptedPlugin#autoImport*"),
|
||||
exclude[IncompatibleResultTypeProblem]("sbt.ScriptedPlugin.requires"),
|
||||
exclude[DirectMissingMethodProblem]("sbt.ScriptedPlugin.scriptedParser"),
|
||||
),
|
||||
)
|
||||
.configure(addSbtCompilerClasspath)
|
||||
|
||||
|
|
@ -417,7 +424,7 @@ lazy val mainSettingsProj = (project in file("main-settings"))
|
|||
// The main integration project for sbt. It brings all of the projects together, configures them, and provides for overriding conventions.
|
||||
lazy val mainProj = (project in file("main"))
|
||||
.enablePlugins(ContrabandPlugin)
|
||||
.dependsOn(logicProj, actionsProj, mainSettingsProj, runProj, commandProj, collectionProj)
|
||||
.dependsOn(logicProj, actionsProj, mainSettingsProj, runProj, commandProj, collectionProj, scriptedSbtProj)
|
||||
.settings(
|
||||
testedBaseSettings,
|
||||
name := "Main",
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ object PluginDiscovery {
|
|||
"sbt.plugins.IvyPlugin" -> sbt.plugins.IvyPlugin,
|
||||
"sbt.plugins.JvmPlugin" -> sbt.plugins.JvmPlugin,
|
||||
"sbt.plugins.CorePlugin" -> sbt.plugins.CorePlugin,
|
||||
"sbt.plugins.ScriptedPlugin" -> sbt.plugins.ScriptedPlugin,
|
||||
"sbt.plugins.SbtPlugin" -> sbt.plugins.SbtPlugin,
|
||||
"sbt.plugins.JUnitXmlReportPlugin" -> sbt.plugins.JUnitXmlReportPlugin,
|
||||
"sbt.plugins.Giter8TemplatePlugin" -> sbt.plugins.Giter8TemplatePlugin
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* sbt
|
||||
* Copyright 2011 - 2017, Lightbend, Inc.
|
||||
* Copyright 2008 - 2010, Mark Harrah
|
||||
* Licensed under BSD-3-Clause license (see LICENSE)
|
||||
*/
|
||||
|
||||
package sbt
|
||||
package plugins
|
||||
|
||||
import Keys._
|
||||
|
||||
object SbtPlugin extends AutoPlugin {
|
||||
override def requires = ScriptedPlugin
|
||||
|
||||
override lazy val projectSettings = Seq(
|
||||
sbtPlugin := true
|
||||
)
|
||||
}
|
||||
|
|
@ -6,13 +6,21 @@
|
|||
*/
|
||||
|
||||
package sbt
|
||||
package plugins
|
||||
|
||||
import java.io.File
|
||||
import Def.Initialize
|
||||
import Keys._
|
||||
import sbt.internal.util.complete.{ Parser, DefaultParsers }
|
||||
import sbt.internal.inc.classpath.ClasspathUtilities
|
||||
import sbt.internal.inc.ModuleUtilities
|
||||
import java.lang.reflect.Method
|
||||
import sbt.librarymanagement._
|
||||
import sbt.librarymanagement.syntax._
|
||||
import sbt.io._
|
||||
import sbt.io.syntax._
|
||||
import Project._
|
||||
import Def._
|
||||
|
||||
object ScriptedPlugin extends AutoPlugin {
|
||||
override def requires = plugins.JvmPlugin
|
||||
|
|
@ -38,6 +46,7 @@ object ScriptedPlugin extends AutoPlugin {
|
|||
val scriptedDependencies = TaskKey[Unit]("scripted-dependencies")
|
||||
val scripted = InputKey[Unit]("scripted")
|
||||
}
|
||||
|
||||
import autoImport._
|
||||
override lazy val projectSettings = Seq(
|
||||
ivyConfigurations ++= Seq(ScriptedConf, ScriptedLaunchConf),
|
||||
|
|
@ -66,7 +75,7 @@ object ScriptedPlugin extends AutoPlugin {
|
|||
scriptedRun := scriptedRunTask.value,
|
||||
scriptedDependencies := {
|
||||
def use[A](@deprecated("unused", "") x: A*): Unit = () // avoid unused warnings
|
||||
val analysis = (compile in Test).value
|
||||
val analysis = (Keys.compile in Test).value
|
||||
val pub = (publishLocal).value
|
||||
use(analysis, pub)
|
||||
},
|
||||
|
|
@ -143,7 +152,6 @@ object ScriptedPlugin extends AutoPlugin {
|
|||
//(token(Space) ~> matched(testID)).*
|
||||
(token(Space) ~> (PagedIds | testIdAsGroup)).* map (_.flatten)
|
||||
}
|
||||
|
||||
def scriptedTask: Initialize[InputTask[Unit]] = Def.inputTask {
|
||||
val args = scriptedParser(sbtTestDirectory.value).parsed
|
||||
scriptedDependencies.value
|
||||
|
|
@ -164,6 +172,6 @@ object ScriptedPlugin extends AutoPlugin {
|
|||
}
|
||||
|
||||
private[this] def getJars(config: Configuration): Initialize[Task[PathFinder]] = Def.task {
|
||||
PathFinder(Classpaths.managedJars(config, classpathTypes.value, update.value).map(_.data))
|
||||
PathFinder(Classpaths.managedJars(config, classpathTypes.value, Keys.update.value).map(_.data))
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
lazy val root = (project in file("."))
|
||||
.enablePlugins(SbtPlugin)
|
||||
Loading…
Reference in New Issue