mirror of https://github.com/sbt/sbt.git
Work around package name confusion
This works around the name conflict between sbt.test package and sbt.Keys.test. 1. sbt.test package is renamed to sbt.scriptedtest. This allows 1.0 plugins and builds to use `test` to mean `Keys.test`. 2. To keep binary compatibility for sbt 0.13 scripted, I am adding `sbt.test.ScriptedRunner` and `sbt.test.ScriptedTests` in `scripted-plugin` artifact. 3. Another affected user is Giter8 plugin that uses ScriptedPlugin. Since the intereactions are limited to `sbt.ScriptedPlugin.*`, we should be fine here. - https://github.com/foundweekends/giter8/blob/v0.11.0-M2/plugin/src/main/scala-sbt-1.0/giter8/SBTCompat.scala
This commit is contained in:
parent
b05802f63b
commit
c20029ce16
11
build.sbt
11
build.sbt
|
|
@ -268,6 +268,10 @@ lazy val scriptedSbtProj = (project in scriptedPath / "sbt")
|
|||
name := "Scripted sbt",
|
||||
libraryDependencies ++= Seq(launcherInterface % "provided"),
|
||||
mimaSettings,
|
||||
mimaBinaryIssueFilters ++= Seq(
|
||||
// sbt.test package is renamed to sbt.scriptedtest.
|
||||
exclude[MissingClassProblem]("sbt.test.*"),
|
||||
),
|
||||
)
|
||||
.configure(addSbtIO, addSbtUtilLogging, addSbtCompilerInterface, addSbtUtilScripted, addSbtLmCore)
|
||||
|
||||
|
|
@ -278,11 +282,8 @@ lazy val scriptedPluginProj = (project in scriptedPath / "plugin")
|
|||
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"),
|
||||
// scripted plugin has moved into sbt mothership.
|
||||
exclude[MissingClassProblem]("sbt.ScriptedPlugin*")
|
||||
),
|
||||
)
|
||||
.configure(addSbtCompilerClasspath)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
|
||||
package sbt
|
||||
package plugins
|
||||
|
||||
import java.io.File
|
||||
import Def.Initialize
|
||||
|
|
@ -90,7 +89,12 @@ object ScriptedPlugin extends AutoPlugin {
|
|||
private[sbt] def scriptedTestsTask: Initialize[Task[AnyRef]] =
|
||||
Def.task {
|
||||
val loader = ClasspathUtilities.toLoader(scriptedClasspath.value, scalaInstance.value.loader)
|
||||
ModuleUtilities.getObject("sbt.test.ScriptedTests", loader)
|
||||
try {
|
||||
ModuleUtilities.getObject("sbt.scriptedtest.ScriptedTests", loader)
|
||||
} catch {
|
||||
case _: ClassNotFoundException =>
|
||||
ModuleUtilities.getObject("sbt.test.ScriptedTests", loader)
|
||||
}
|
||||
}
|
||||
|
||||
private[sbt] def scriptedRunTask: Initialize[Task[Method]] = Def.taskDyn {
|
||||
|
|
@ -47,7 +47,7 @@ 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.ScriptedPlugin" -> sbt.ScriptedPlugin,
|
||||
"sbt.plugins.SbtPlugin" -> sbt.plugins.SbtPlugin,
|
||||
"sbt.plugins.JUnitXmlReportPlugin" -> sbt.plugins.JUnitXmlReportPlugin,
|
||||
"sbt.plugins.Giter8TemplatePlugin" -> sbt.plugins.Giter8TemplatePlugin
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ object Scripted {
|
|||
sys.props(org.apache.logging.log4j.util.LoaderUtil.IGNORE_TCCL_PROPERTY) = "true"
|
||||
val noJLine = new classpath.FilteredLoader(scriptedSbtInstance.loader, "jline." :: Nil)
|
||||
val loader = classpath.ClasspathUtilities.toLoader(scriptedSbtClasspath.files, noJLine)
|
||||
val bridgeClass = Class.forName("sbt.test.ScriptedRunner", true, loader)
|
||||
val bridgeClass = Class.forName("sbt.scriptedtest.ScriptedRunner", true, loader)
|
||||
val bridge = bridgeClass.getDeclaredConstructor().newInstance().asInstanceOf[SbtScriptedRunner]
|
||||
try {
|
||||
// Using java.util.List to encode File => Unit.
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
sbt.ScriptedPlugin
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* sbt
|
||||
* Copyright 2011 - 2017, Lightbend, Inc.
|
||||
* Copyright 2008 - 2010, Mark Harrah
|
||||
* Licensed under BSD-3-Clause license (see LICENSE)
|
||||
*/
|
||||
|
||||
package sbt
|
||||
|
||||
// ScriptedPlugin has moved to main.
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* sbt
|
||||
* Copyright 2011 - 2017, Lightbend, Inc.
|
||||
* Copyright 2008 - 2010, Mark Harrah
|
||||
* Licensed under BSD-3-Clause license (see LICENSE)
|
||||
*/
|
||||
|
||||
package sbt.test
|
||||
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* This is a bincompat place holder sbt.test package that we are now trying to hide
|
||||
* because of the name conflict with Keys.test.
|
||||
*/
|
||||
@deprecated("Use sbt.scriptedtest.ScriptedRunner.", "1.2.0")
|
||||
private[sbt] class ScriptedRunner extends sbt.scriptedtest.ScriptedRunner
|
||||
|
||||
/**
|
||||
* This is a bincompat place holder for sbt.test package that we are now trying to hide
|
||||
* because of the name conflict with Keys.test.
|
||||
*/
|
||||
@deprecated("Use sbt.scriptedtest.ScriptedTests.", "1.2.0")
|
||||
private[sbt] object ScriptedTests extends ScriptedRunner {
|
||||
|
||||
/** Represents the function that runs the scripted tests, both in single or batch mode. */
|
||||
type TestRunner = () => Seq[Option[String]]
|
||||
|
||||
val emptyCallback: File => Unit = _ => ()
|
||||
def main(args: Array[String]): Unit =
|
||||
sbt.scriptedtest.ScriptedTests.main(args)
|
||||
}
|
||||
|
|
@ -6,10 +6,10 @@
|
|||
*/
|
||||
|
||||
package sbt
|
||||
package test
|
||||
package scriptedtest
|
||||
|
||||
import sbt.internal.scripted._
|
||||
import sbt.test.BatchScriptRunner.States
|
||||
import sbt.scriptedtest.BatchScriptRunner.States
|
||||
|
||||
/** Defines an alternative script runner that allows batch execution. */
|
||||
private[sbt] class BatchScriptRunner extends ScriptRunner {
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
package sbt
|
||||
package test
|
||||
package scriptedtest
|
||||
|
||||
import java.io.{ File, IOException }
|
||||
import xsbt.IPC
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
package sbt
|
||||
package test
|
||||
package scriptedtest
|
||||
|
||||
import java.io.File
|
||||
import java.util.Properties
|
||||
|
|
@ -466,13 +466,13 @@ class ScriptedRunner {
|
|||
final case class ScriptedTest(group: String, name: String) {
|
||||
override def toString = group + "/" + name
|
||||
}
|
||||
private[test] object ListTests {
|
||||
private[sbt] object ListTests {
|
||||
def list(directory: File, filter: java.io.FileFilter) = wrapNull(directory.listFiles(filter))
|
||||
}
|
||||
import ListTests._
|
||||
private[test] final class ListTests(baseDirectory: File,
|
||||
accept: ScriptedTest => Boolean,
|
||||
log: Logger) {
|
||||
private[sbt] final class ListTests(baseDirectory: File,
|
||||
accept: ScriptedTest => Boolean,
|
||||
log: Logger) {
|
||||
def filter = DirectoryFilter -- HiddenFileFilter
|
||||
def listTests: Seq[ScriptedTest] = {
|
||||
list(baseDirectory, filter) flatMap { group =>
|
||||
Loading…
Reference in New Issue