mirror of https://github.com/sbt/sbt.git
migrate PluginTrigger and ProjectOrigin to Contraband (#3191)
and move TestFramework to a non case class.
This commit is contained in:
parent
50cc045a70
commit
d3ff3fb63a
|
|
@ -270,11 +270,15 @@ 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(actionsProj, mainSettingsProj, runProj, commandProj)
|
||||
.settings(
|
||||
testedBaseSettings,
|
||||
name := "Main",
|
||||
libraryDependencies ++= scalaXml.value ++ Seq(launcherInterface)
|
||||
libraryDependencies ++= scalaXml.value ++ Seq(launcherInterface),
|
||||
managedSourceDirectories in Compile +=
|
||||
baseDirectory.value / "src" / "main" / "contraband-scala",
|
||||
sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala"
|
||||
)
|
||||
.configure(addSbtCompilerInterface,
|
||||
addSbtIO,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]].
|
||||
*/
|
||||
|
||||
// DO NOT EDIT MANUALLY
|
||||
package sbt
|
||||
/**
|
||||
* Type for AutoPlugin's trigger method.
|
||||
* Determines whether an AutoPlugin will be activated for a project when the
|
||||
* `requires` clause is satisfied.
|
||||
*/
|
||||
sealed abstract class PluginTrigger extends Serializable
|
||||
object PluginTrigger {
|
||||
|
||||
|
||||
case object AllRequirements extends PluginTrigger
|
||||
case object NoTrigger extends PluginTrigger
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]].
|
||||
*/
|
||||
|
||||
// DO NOT EDIT MANUALLY
|
||||
package sbt
|
||||
/**
|
||||
* Indicate whether the project was created organically, synthesized by a plugin,
|
||||
* or is a "generic root" project supplied by sbt when a project doesn't exist for `file(".")`.
|
||||
*/
|
||||
sealed abstract class ProjectOrigin extends Serializable
|
||||
object ProjectOrigin {
|
||||
|
||||
|
||||
case object Organic extends ProjectOrigin
|
||||
case object ExtraProject extends ProjectOrigin
|
||||
case object DerivedProject extends ProjectOrigin
|
||||
case object GenericRoot extends ProjectOrigin
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package sbt
|
||||
@target(Scala)
|
||||
|
||||
## Indicate whether the project was created organically, synthesized by a plugin,
|
||||
## or is a "generic root" project supplied by sbt when a project doesn't exist for `file(".")`.
|
||||
enum ProjectOrigin {
|
||||
Organic
|
||||
ExtraProject
|
||||
DerivedProject
|
||||
GenericRoot
|
||||
}
|
||||
|
||||
## Type for AutoPlugin's trigger method.
|
||||
## Determines whether an AutoPlugin will be activated for a project when the
|
||||
## `requires` clause is satisfied.
|
||||
enum PluginTrigger {
|
||||
AllRequirements
|
||||
NoTrigger
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ import Def.Setting
|
|||
import Plugins._
|
||||
import annotation.tailrec
|
||||
import sbt.util.Logger
|
||||
import PluginTrigger._
|
||||
|
||||
/**
|
||||
* An AutoPlugin defines a group of settings and the conditions where the settings are automatically added to a build (called "activation").
|
||||
|
|
@ -135,10 +136,6 @@ object AutoPluginException {
|
|||
new AutoPluginException(Plugins.translateMessage(origin), Some(origin))
|
||||
}
|
||||
|
||||
sealed trait PluginTrigger
|
||||
case object AllRequirements extends PluginTrigger
|
||||
case object NoTrigger extends PluginTrigger
|
||||
|
||||
/** An expression that matches `AutoPlugin`s. */
|
||||
sealed trait Plugins {
|
||||
def &&(o: Basic): Plugins
|
||||
|
|
|
|||
|
|
@ -327,18 +327,6 @@ final case class ResolvedClasspathDependency(project: ProjectRef, configuration:
|
|||
final case class ClasspathDependency(project: ProjectReference, configuration: Option[String])
|
||||
extends ClasspathDep[ProjectReference]
|
||||
|
||||
/**
|
||||
* Indicate whether the project was created organically, synthesized by a plugin,
|
||||
* or is a "generic root" project supplied by sbt when a project doesn't exist for `file(".")`.
|
||||
*/
|
||||
sealed trait ProjectOrigin
|
||||
object ProjectOrigin {
|
||||
case object Organic extends ProjectOrigin
|
||||
case object ExtraProject extends ProjectOrigin
|
||||
case object DerivedProject extends ProjectOrigin
|
||||
case object GenericRoot extends ProjectOrigin
|
||||
}
|
||||
|
||||
object Project extends ProjectExtra {
|
||||
|
||||
private abstract class ProjectDef[PR <: ProjectReference](
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ trait Import {
|
|||
val LoggedOutput = sbt.OutputStrategy.LoggedOutput
|
||||
type CustomOutput = sbt.OutputStrategy.CustomOutput
|
||||
val CustomOutput = sbt.OutputStrategy.CustomOutput
|
||||
val AllRequirements = sbt.PluginTrigger.AllRequirements
|
||||
val NoTrigger = sbt.PluginTrigger.NoTrigger
|
||||
|
||||
// sbt.testing
|
||||
type TestResult = sbt.protocol.testing.TestResult
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ final class ScriptedTests(resourceBaseDirectory: File,
|
|||
s"""
|
||||
|import sbt._, Keys._
|
||||
|object InstrumentScripted extends AutoPlugin {
|
||||
| override def trigger = AllRequirements
|
||||
| override def trigger = allRequirements
|
||||
| override def globalSettings: Seq[Setting[_]] =
|
||||
| Seq(commands += setUpScripted) ++ super.globalSettings
|
||||
|
|
||||
|
|
|
|||
|
|
@ -15,16 +15,27 @@ import sbt.io.IO
|
|||
import sbt.protocol.testing.TestResult
|
||||
|
||||
object TestFrameworks {
|
||||
val ScalaCheck = new TestFramework("org.scalacheck.ScalaCheckFramework")
|
||||
val ScalaCheck = TestFramework("org.scalacheck.ScalaCheckFramework")
|
||||
val ScalaTest =
|
||||
new TestFramework("org.scalatest.tools.Framework", "org.scalatest.tools.ScalaTestFramework")
|
||||
val Specs = new TestFramework("org.specs.runner.SpecsFramework")
|
||||
TestFramework("org.scalatest.tools.Framework", "org.scalatest.tools.ScalaTestFramework")
|
||||
val Specs = TestFramework("org.specs.runner.SpecsFramework")
|
||||
val Specs2 =
|
||||
new TestFramework("org.specs2.runner.Specs2Framework", "org.specs2.runner.SpecsFramework")
|
||||
val JUnit = new TestFramework("com.novocode.junit.JUnitFramework")
|
||||
TestFramework("org.specs2.runner.Specs2Framework", "org.specs2.runner.SpecsFramework")
|
||||
val JUnit = TestFramework("com.novocode.junit.JUnitFramework")
|
||||
}
|
||||
|
||||
case class TestFramework(implClassNames: String*) {
|
||||
final class TestFramework(val implClassNames: String*) extends Serializable {
|
||||
override def equals(o: Any): Boolean = o match {
|
||||
case x: TestFramework => (this.implClassNames.toList == x.implClassNames.toList)
|
||||
case _ => false
|
||||
}
|
||||
override def hashCode: Int = {
|
||||
37 * (17 + implClassNames.##) + "TestFramework".##
|
||||
}
|
||||
override def toString: String = {
|
||||
"TestFramework(" + implClassNames.mkString(", ") + ")"
|
||||
}
|
||||
|
||||
@tailrec
|
||||
private def createFramework(loader: ClassLoader,
|
||||
log: ManagedLogger,
|
||||
|
|
@ -108,6 +119,8 @@ final class TestRunner(delegate: Runner, listeners: Seq[TestReportListener], log
|
|||
}
|
||||
|
||||
object TestFramework {
|
||||
def apply(implClassNames: String*): TestFramework = new TestFramework(implClassNames: _*)
|
||||
|
||||
def getFingerprints(framework: Framework): Seq[Fingerprint] =
|
||||
framework.getClass.getMethod("fingerprints").invoke(framework) match {
|
||||
case fingerprints: Array[Fingerprint] => fingerprints.toList
|
||||
|
|
|
|||
Loading…
Reference in New Issue