mirror of https://github.com/sbt/sbt.git
Merge pull request #2575 from eed3si9n/wip/remove_plugin
[sbt 1.0] Rename sbt.Plugin => sbt.internal.OldPlugin
This commit is contained in:
commit
b285cf114d
|
|
@ -1,6 +1,7 @@
|
|||
package sbt
|
||||
|
||||
import sbt.internal.util.Types.const
|
||||
import sbt.internal.OldPlugin
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
|
|
@ -12,7 +13,7 @@ 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: Plugin => Boolean) 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
|
||||
|
|
@ -36,7 +37,7 @@ object AddSettings {
|
|||
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: Plugin => Boolean): AddSettings = new Plugins(include)
|
||||
def plugins(include: OldPlugin => Boolean): AddSettings = new Plugins(include)
|
||||
|
||||
/** Includes user settings in the project. */
|
||||
val userSettings: AddSettings = User
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import Def.{ displayFull, ScopedKey, ScopeLocal, Setting }
|
|||
import BuildPaths.outputDirectory
|
||||
import Scope.GlobalScope
|
||||
import BuildStreams.Streams
|
||||
import sbt.internal.{ BuildDef, Load }
|
||||
import sbt.internal.{ BuildDef, Load, OldPlugin }
|
||||
import sbt.io.Path._
|
||||
import sbt.internal.util.{ Attributed, AttributeEntry, AttributeKey, AttributeMap, Settings }
|
||||
import sbt.internal.util.Attributed.data
|
||||
|
|
@ -123,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[BuildDef]) {
|
||||
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) ++
|
||||
BuildUtil.importAllRoot(autoImports(autoPluginAutoImports)) ++
|
||||
|
|
@ -169,19 +169,13 @@ final class DetectedPlugins(val plugins: DetectedModules[Plugin], val autoPlugin
|
|||
*/
|
||||
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[Plugin], pluginNames: Seq[String]) =
|
||||
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))
|
||||
)
|
||||
|
||||
@deprecated("Use detected.plugins.values.", "0.13.2")
|
||||
val plugins: Seq[Plugin] = detected.plugins.values
|
||||
@deprecated("Use detected.plugins.names.", "0.13.2")
|
||||
val pluginNames: Seq[String] = detected.plugins.names
|
||||
|
||||
def fullClasspath: Seq[Attributed[File]] = pluginData.classpath
|
||||
def classpath = data(fullClasspath)
|
||||
|
||||
}
|
||||
/**
|
||||
* The loaded, but unresolved build unit.
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import sbt.internal.inc.{ Analysis, ClassfileManager, ClasspathOptions, Compiler
|
|||
import testing.{ Framework, Runner, AnnotatedFingerprint, SubclassFingerprint }
|
||||
|
||||
import sbt.librarymanagement.{ `package` => _, _ }
|
||||
import sbt.internal.OldPlugin
|
||||
import sbt.internal.librarymanagement._
|
||||
import sbt.internal.librarymanagement.syntax._
|
||||
import sbt.internal.util._
|
||||
|
|
@ -297,7 +298,7 @@ object Defaults extends BuildCommon {
|
|||
console <<= consoleTask,
|
||||
consoleQuick <<= consoleQuickTask,
|
||||
discoveredMainClasses <<= compile map discoverMainClasses storeAs discoveredMainClasses xtriggeredBy compile,
|
||||
definedSbtPlugins <<= discoverPlugins,
|
||||
// definedSbtPlugins <<= discoverPlugins,
|
||||
discoveredSbtPlugins <<= discoverSbtPluginNames,
|
||||
inTask(run)(runnerTask :: Nil).head,
|
||||
selectMainClass := mainClass.value orElse askForMainClass(discoveredMainClasses.value),
|
||||
|
|
@ -307,6 +308,7 @@ object Defaults extends BuildCommon {
|
|||
runMain <<= runMainTask(fullClasspath, runner in run),
|
||||
copyResources <<= copyResourcesTask
|
||||
)
|
||||
|
||||
private[this] lazy val configGlobal = globalDefaults(Seq(
|
||||
initialCommands :== "",
|
||||
cleanupCommands :== ""
|
||||
|
|
@ -942,13 +944,6 @@ object Defaults extends BuildCommon {
|
|||
if (sbtPlugin.value) PluginDiscovery.discoverSourceAll(compile.value) else PluginDiscovery.emptyDiscoveredNames
|
||||
}
|
||||
|
||||
@deprecated("Use discoverSbtPluginNames.", "0.13.2")
|
||||
def discoverPlugins: Initialize[Task[Set[String]]] = (compile, sbtPlugin, streams) map { (analysis, isPlugin, s) => if (isPlugin) discoverSbtPlugins(analysis, s.log) else Set.empty }
|
||||
|
||||
@deprecated("Use PluginDiscovery.sourceModuleNames[Plugin].", "0.13.2")
|
||||
def discoverSbtPlugins(analysis: CompileAnalysis, log: Logger): Set[String] =
|
||||
PluginDiscovery.sourceModuleNames(analysis, classOf[Plugin].getName).toSet
|
||||
|
||||
def copyResourcesTask =
|
||||
(classDirectory, resources, resourceDirectories, streams) map { (target, resrcs, dirs, s) =>
|
||||
val cacheFile = s.cacheDirectory / "copy-resources"
|
||||
|
|
|
|||
|
|
@ -176,7 +176,6 @@ object Keys {
|
|||
val crossScalaVersions = SettingKey[Seq[String]]("cross-scala-versions", "The versions of Scala used when cross-building.", BPlusSetting)
|
||||
val crossVersion = SettingKey[CrossVersion]("cross-version", "Configures handling of the Scala version when cross-building.", CSetting)
|
||||
val classpathOptions = SettingKey[ClasspathOptions]("classpath-options", "Configures handling of Scala classpaths.", DSetting)
|
||||
val definedSbtPlugins = TaskKey[Set[String]]("defined-sbt-plugins", "The set of names of Plugin implementations defined by this project.", CTask)
|
||||
val discoveredSbtPlugins = TaskKey[PluginDiscovery.DiscoveredNames]("discovered-sbt-plugins", "The names of sbt plugin-related modules (modules that extend Build, Plugin, AutoPlugin) defined by this project.", CTask)
|
||||
val sbtPlugin = SettingKey[Boolean]("sbt-plugin", "If true, enables adding sbt as a dependency and auto-generation of the plugin descriptor file.", BMinusSetting)
|
||||
val printWarnings = TaskKey[Unit]("print-warnings", "Shows warnings from compilation, including ones that weren't printed initially.", BPlusTask)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package sbt
|
||||
|
||||
import sbt.internal.util.Attributed
|
||||
import sbt.internal.{ BuildDef, IncompatiblePluginsException }
|
||||
import sbt.internal.{ BuildDef, IncompatiblePluginsException, OldPlugin }
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import Attributed.data
|
||||
|
|
@ -45,7 +45,7 @@ object PluginDiscovery {
|
|||
case (name, value) =>
|
||||
DetectedAutoPlugin(name, value, sbt.Plugins.hasAutoImportGetter(value, loader))
|
||||
}
|
||||
new DetectedPlugins(discover[Plugin](Plugins), allAutoPlugins, discover[BuildDef](Builds))
|
||||
new DetectedPlugins(discover[OldPlugin](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[BuildDef])
|
||||
new DiscoveredNames(discover[OldPlugin], discover[AutoPlugin], discover[BuildDef])
|
||||
}
|
||||
|
||||
// TODO: for 0.14.0, consider consolidating into a single file, which would make the classpath search 4x faster
|
||||
|
|
|
|||
|
|
@ -221,7 +221,6 @@ private[sbt] object Load {
|
|||
case (uri, build) =>
|
||||
val plugins = build.unit.plugins.detected.plugins.values
|
||||
val pluginBuildSettings = plugins.flatMap(_.buildSettings) ++ loaded.autos.buildSettings(uri)
|
||||
val pluginNotThis = plugins.flatMap(_.settings) filterNot isProjectThis
|
||||
val projectSettings = build.defined flatMap {
|
||||
case (id, project) =>
|
||||
val ref = ProjectRef(uri, id)
|
||||
|
|
@ -233,7 +232,7 @@ private[sbt] object Load {
|
|||
}
|
||||
val buildScope = Scope(Select(BuildRef(uri)), Global, Global, Global)
|
||||
val buildBase = baseDirectory :== build.localBase
|
||||
val buildSettings = transformSettings(buildScope, uri, rootProject, pluginNotThis ++ pluginBuildSettings ++ (buildBase +: build.buildSettings))
|
||||
val buildSettings = transformSettings(buildScope, uri, rootProject, pluginBuildSettings ++ (buildBase +: build.buildSettings))
|
||||
buildSettings ++ projectSettings
|
||||
}
|
||||
}
|
||||
|
|
@ -244,10 +243,6 @@ private[sbt] object Load {
|
|||
build.unit.plugins.detected.plugins.values flatMap { _.globalSettings }
|
||||
}
|
||||
|
||||
@deprecated("No longer used.", "0.13.0")
|
||||
def extractSettings(plugins: Seq[Plugin]): (Seq[Setting[_]], Seq[Setting[_]], Seq[Setting[_]]) =
|
||||
(plugins.flatMap(_.settings), plugins.flatMap(_.projectSettings), plugins.flatMap(_.buildSettings))
|
||||
|
||||
def transformProjectOnly(uri: URI, rootProject: URI => String, settings: Seq[Setting[_]]): Seq[Setting[_]] =
|
||||
Project.transform(Scope.resolveProject(uri, rootProject), settings)
|
||||
def transformSettings(thisScope: Scope, uri: URI, rootProject: URI => String, settings: Seq[Setting[_]]): Seq[Setting[_]] =
|
||||
|
|
@ -679,7 +674,7 @@ private[sbt] object Load {
|
|||
// 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.settings.filter(isProjectThis) ++ p.projectSettings)
|
||||
included.flatMap(p => p.projectSettings)
|
||||
}
|
||||
// Filter the AutoPlugin settings we included based on which ones are
|
||||
// intended in the AddSettings.AutoPlugins filter.
|
||||
|
|
@ -860,29 +855,10 @@ private[sbt] object Load {
|
|||
def loadPlugins(dir: File, data: PluginData, loader: ClassLoader): sbt.LoadedPlugins =
|
||||
new sbt.LoadedPlugins(dir, data, loader, PluginDiscovery.discoverAll(data, loader))
|
||||
|
||||
@deprecated("Replaced by the more general PluginDiscovery.binarySourceModuleNames and will be made private.", "0.13.2")
|
||||
def getPluginNames(classpath: Seq[Attributed[File]], loader: ClassLoader): Seq[String] =
|
||||
PluginDiscovery.binarySourceModuleNames(classpath, loader, PluginDiscovery.Paths.Plugins, classOf[Plugin].getName)
|
||||
|
||||
@deprecated("Use PluginDiscovery.binaryModuleNames.", "0.13.2")
|
||||
def binaryPlugins(classpath: Seq[File], loader: ClassLoader): Seq[String] =
|
||||
PluginDiscovery.binaryModuleNames(classpath, loader, PluginDiscovery.Paths.Plugins)
|
||||
|
||||
@deprecated("Use PluginDiscovery.onClasspath", "0.13.2")
|
||||
def onClasspath(classpath: Seq[File])(url: URL): Boolean =
|
||||
PluginDiscovery.onClasspath(classpath)(url)
|
||||
|
||||
@deprecated("Use ModuleUtilities.getCheckedObjects[Plugin].", "0.13.2")
|
||||
def loadPlugins(loader: ClassLoader, pluginNames: Seq[String]): Seq[Plugin] =
|
||||
ModuleUtilities.getCheckedObjects[Plugin](pluginNames, loader).map(_._2)
|
||||
|
||||
@deprecated("Use ModuleUtilities.getCheckedObject[Plugin].", "0.13.2")
|
||||
def loadPlugin(pluginName: String, loader: ClassLoader): Plugin =
|
||||
ModuleUtilities.getCheckedObject[Plugin](pluginName, loader)
|
||||
|
||||
@deprecated("No longer used.", "0.13.2")
|
||||
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.internal.BuildDef")
|
||||
|
||||
|
|
@ -951,7 +927,9 @@ final case class LoadBuildConfiguration(
|
|||
extraBuilds: Seq[URI],
|
||||
log: Logger) {
|
||||
lazy val (globalPluginClasspath, globalPluginLoader) = Load.pluginDefinitionLoader(this, Load.globalPluginClasspath(globalPlugin))
|
||||
lazy val globalPluginNames = if (globalPluginClasspath.isEmpty) Nil else Load.getPluginNames(globalPluginClasspath, globalPluginLoader)
|
||||
lazy val globalPluginNames =
|
||||
if (globalPluginClasspath.isEmpty) Nil
|
||||
else PluginDiscovery.binarySourceModuleNames(classpath, loader, PluginDiscovery.Paths.Plugins, classOf[OldPlugin].getName)
|
||||
|
||||
private[sbt] lazy val globalPluginDefs = {
|
||||
val pluginData = globalPlugin match {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
package sbt
|
||||
package internal
|
||||
|
||||
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
|
||||
|
||||
@deprecated("Use AutoPlugin", "0.13.8")
|
||||
trait OldPlugin {
|
||||
/** Settings to be appended to all projects in a build. */
|
||||
def projectSettings: Seq[Setting[_]] = Nil
|
||||
|
||||
|
|
@ -4,7 +4,7 @@ import java.io._
|
|||
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
import sbt.internal.{ Load, BuildDef }
|
||||
import sbt.internal.{ Load, BuildDef, OldPlugin }
|
||||
import sbt.internal.util.{ AttributeEntry, AttributeMap, ConsoleOut, GlobalLogging, MainLogging, Settings }
|
||||
|
||||
object PluginCommandTestPlugin0 extends AutoPlugin
|
||||
|
|
@ -83,7 +83,7 @@ object FakeState {
|
|||
)
|
||||
|
||||
val pluginData = PluginData(Nil, Nil, None, None, Nil)
|
||||
val detectedModules: DetectedModules[Plugin] = new DetectedModules(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))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
|
||||
object DefPlugin extends Plugin {
|
||||
val aValue = "demo"
|
||||
object DefPlugin extends AutoPlugin {
|
||||
override val requires = plugins.JvmPlugin
|
||||
override val trigger = allRequirements
|
||||
|
||||
object autoImport {
|
||||
val aValue = "demo"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,29 @@
|
|||
import sbt._
|
||||
|
||||
object Q extends Plugin {
|
||||
val zyx = -3
|
||||
object Q extends AutoPlugin {
|
||||
override val requires = plugins.JvmPlugin
|
||||
override val trigger = allRequirements
|
||||
|
||||
object autoImport {
|
||||
val zyx = -3
|
||||
}
|
||||
}
|
||||
|
||||
package name.example {
|
||||
object P extends AutoPlugin {
|
||||
override val requires = plugins.JvmPlugin
|
||||
override val trigger = allRequirements
|
||||
|
||||
object P extends Plugin {
|
||||
val xyz = 3
|
||||
val checkMaxErrors = TaskKey[Unit]("check-max-errors")
|
||||
val checkName = TaskKey[Unit]("check-name")
|
||||
object autoImport {
|
||||
val xyz = 3
|
||||
val checkMaxErrors = TaskKey[Unit]("check-max-errors")
|
||||
val checkName = TaskKey[Unit]("check-name")
|
||||
}
|
||||
|
||||
override def settings = Seq[Setting[_]](
|
||||
checkMaxErrors <<= Keys.maxErrors map { me => assert(me == xyz, "Expected maxErrors to be " + xyz + ", but it was " + me ) },
|
||||
checkName <<= Keys.name map { n => assert(n == "Demo", "Expected name to be 'Demo', but it was '" + n + "'" ) }
|
||||
)
|
||||
import autoImport._
|
||||
override def projectSettings = Seq[Setting[_]](
|
||||
checkMaxErrors <<= Keys.maxErrors map { me => assert(me == xyz, "Expected maxErrors to be " + xyz + ", but it was " + me ) },
|
||||
checkName <<= Keys.name map { n => assert(n == "Demo", "Expected name to be 'Demo', but it was '" + n + "'" ) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
import sbt._
|
||||
|
||||
object GlobalLegacyPlugin extends sbt.Plugin {
|
||||
import sbt.Keys._
|
||||
val globalLegacyPluginSetting = SettingKey[String]("A top level setting declared by a legacy plugin")
|
||||
val useGlobalLegacyPluginSetting = globalLegacyPluginSetting in Global
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
/*
|
||||
If the GlobalLegacyPlugin 'in' statements do not register and get
|
||||
brought in to the global scope, this will fail
|
||||
*/
|
||||
globalLegacyPluginSetting := "foo"
|
||||
|
|
@ -1 +0,0 @@
|
|||
ScriptedPlugin.scriptedSettings
|
||||
|
|
@ -1,9 +1,11 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
|
||||
object P extends Plugin
|
||||
{
|
||||
override def settings = Seq(
|
||||
maxErrors ~= (x => x*x)
|
||||
)
|
||||
object P extends AutoPlugin {
|
||||
override val requires = plugins.JvmPlugin
|
||||
override val trigger = allRequirements
|
||||
|
||||
override def projectSettings = Seq(
|
||||
maxErrors ~= (x => x*x)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ $ copy-file changes/local.sbt local.sbt
|
|||
> check 7
|
||||
|
||||
# square
|
||||
# plugins, global.sbt, and then local.sbt = (100 * 100) / 25 + 3
|
||||
$ copy-file changes/Global.scala global/plugins/Global.scala
|
||||
> reload
|
||||
> check 19
|
||||
> check 403
|
||||
|
|
|
|||
|
|
@ -1,9 +1,15 @@
|
|||
import sbt._
|
||||
|
||||
object TestPlugin extends Plugin
|
||||
{
|
||||
val Check = TaskKey[Unit]("check")
|
||||
override def settings = Seq(
|
||||
Check := assert(JavaTest.X == 9)
|
||||
)
|
||||
}
|
||||
object TestPlugin extends AutoPlugin {
|
||||
override val requires = plugins.JvmPlugin
|
||||
override val trigger = allRequirements
|
||||
|
||||
object autoImport {
|
||||
val Check = TaskKey[Unit]("check")
|
||||
}
|
||||
import autoImport._
|
||||
|
||||
override def projectSettings = Seq(
|
||||
Check := assert(JavaTest.X == 9)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,22 +15,41 @@ import sbt.librarymanagement.Configuration
|
|||
|
||||
import sbt.io.{ AllPassFilter, PathFinder }
|
||||
|
||||
object ScriptedPlugin extends Plugin {
|
||||
def scriptedConf = config("scripted-sbt") hide
|
||||
def scriptedLaunchConf = config("scripted-sbt-launch") hide
|
||||
|
||||
val scriptedSbt = SettingKey[String]("scripted-sbt")
|
||||
val sbtLauncher = TaskKey[File]("sbt-launcher")
|
||||
|
||||
val sbtTestDirectory = SettingKey[File]("sbt-test-directory")
|
||||
val scriptedBufferLog = SettingKey[Boolean]("scripted-buffer-log")
|
||||
|
||||
val scriptedClasspath = TaskKey[PathFinder]("scripted-classpath")
|
||||
val scriptedTests = TaskKey[AnyRef]("scripted-tests")
|
||||
val scriptedRun = TaskKey[Method]("scripted-run")
|
||||
val scriptedLaunchOpts = SettingKey[Seq[String]]("scripted-launch-opts", "options to pass to jvm launching scripted tasks")
|
||||
val scriptedDependencies = TaskKey[Unit]("scripted-dependencies")
|
||||
val scripted = InputKey[Unit]("scripted")
|
||||
object ScriptedPlugin extends AutoPlugin {
|
||||
override def requires = plugins.JvmPlugin
|
||||
override def trigger = allRequirements
|
||||
object autoImport {
|
||||
def scriptedConf = config("scripted-sbt") hide
|
||||
def scriptedLaunchConf = config("scripted-sbt-launch") hide
|
||||
val scriptedSbt = SettingKey[String]("scripted-sbt")
|
||||
val sbtLauncher = TaskKey[File]("sbt-launcher")
|
||||
val sbtTestDirectory = SettingKey[File]("sbt-test-directory")
|
||||
val scriptedBufferLog = SettingKey[Boolean]("scripted-buffer-log")
|
||||
val scriptedClasspath = TaskKey[PathFinder]("scripted-classpath")
|
||||
val scriptedTests = TaskKey[AnyRef]("scripted-tests")
|
||||
val scriptedRun = TaskKey[Method]("scripted-run")
|
||||
val scriptedLaunchOpts = SettingKey[Seq[String]]("scripted-launch-opts", "options to pass to jvm launching scripted tasks")
|
||||
val scriptedDependencies = TaskKey[Unit]("scripted-dependencies")
|
||||
val scripted = InputKey[Unit]("scripted")
|
||||
}
|
||||
import autoImport._
|
||||
override lazy val projectSettings = Seq(
|
||||
ivyConfigurations ++= Seq(scriptedConf, scriptedLaunchConf),
|
||||
scriptedSbt := sbtVersion.value,
|
||||
sbtLauncher <<= getJars(scriptedLaunchConf).map(_.get.head),
|
||||
sbtTestDirectory := sourceDirectory.value / "sbt-test",
|
||||
libraryDependencies ++= Seq(
|
||||
"org.scala-sbt" % "scripted-sbt" % scriptedSbt.value % scriptedConf.toString,
|
||||
"org.scala-sbt" % "sbt-launch" % scriptedSbt.value % scriptedLaunchConf.toString
|
||||
),
|
||||
scriptedBufferLog := true,
|
||||
scriptedClasspath := getJars(scriptedConf).value,
|
||||
scriptedTests <<= scriptedTestsTask,
|
||||
scriptedRun <<= scriptedRunTask,
|
||||
scriptedDependencies <<= (compile in Test, publishLocal) map { (analysis, pub) => Unit },
|
||||
scriptedLaunchOpts := Seq(),
|
||||
scripted <<= scriptedTask
|
||||
)
|
||||
|
||||
def scriptedTestsTask: Initialize[Task[AnyRef]] = (scriptedClasspath, scalaInstance) map {
|
||||
(classpath, scala) =>
|
||||
|
|
@ -69,23 +88,6 @@ object ScriptedPlugin extends Plugin {
|
|||
} catch { case e: java.lang.reflect.InvocationTargetException => throw e.getCause }
|
||||
}
|
||||
|
||||
val scriptedSettings = Seq(
|
||||
ivyConfigurations ++= Seq(scriptedConf, scriptedLaunchConf),
|
||||
scriptedSbt := sbtVersion.value,
|
||||
sbtLauncher <<= getJars(scriptedLaunchConf).map(_.get.head),
|
||||
sbtTestDirectory := sourceDirectory.value / "sbt-test",
|
||||
libraryDependencies ++= Seq(
|
||||
"org.scala-sbt" % "scripted-sbt" % scriptedSbt.value % scriptedConf.toString,
|
||||
"org.scala-sbt" % "sbt-launch" % scriptedSbt.value % scriptedLaunchConf.toString
|
||||
),
|
||||
scriptedBufferLog := true,
|
||||
scriptedClasspath := getJars(scriptedConf).value,
|
||||
scriptedTests <<= scriptedTestsTask,
|
||||
scriptedRun <<= scriptedRunTask,
|
||||
scriptedDependencies <<= (compile in Test, publishLocal) map { (analysis, pub) => Unit },
|
||||
scriptedLaunchOpts := Seq(),
|
||||
scripted <<= scriptedTask
|
||||
)
|
||||
private[this] def getJars(config: Configuration): Initialize[Task[PathFinder]] = Def.task {
|
||||
PathFinder(Classpaths.managedJars(config, classpathTypes.value, update.value).map(_.data))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue