Merge pull request #2956 from eed3si9n/wip/allsyntax

[sbt 1.0] Remove sbt.syntax
This commit is contained in:
Dale Wijnand 2017-02-08 09:33:53 +00:00 committed by GitHub
commit f04bc2911d
24 changed files with 80 additions and 90 deletions

View File

@ -1,7 +1,7 @@
Migration notes
===============
- Build definition is based on Scala 2.11.8
- Build definition is based on Scala 2.12.1
- Build.scala style builds are gone. Use multi-project `build.sbt`.
- `Project(...)` constructor is restricted down to two parameters. Use `project` instead.
- `sbt.Plugin` is also gone. Use auto plugins.
@ -13,10 +13,3 @@ Migration notes
- Renames early command feature from `--<command>` to `early(<command>)`.
- Log options `-error`, `-warn`, `-info`, `-debug` are added as shorthand for `"early(error)"` etc.
- `sbt.Process` and `sbt.ProcessExtra` are gone. Use `scala.sys.process` instead.
#### Additional import required
Implicit conversions are moved to `sbt.syntax`. Add the following imports to auto plugins
or `project/*.scala`.
import sbt._, syntax._, Keys._

View File

@ -73,7 +73,7 @@ object BuildUtil {
}
}
def baseImports: Seq[String] = "import scala.xml.{TopScope=>$scope}" :: "import sbt._, Keys._, syntax._" :: Nil
def baseImports: Seq[String] = "import _root_.scala.xml.{TopScope=>$scope}" :: "import _root_.sbt._" :: "import _root_.sbt.Keys._" :: Nil
def getImports(unit: BuildUnit): Seq[String] = unit.plugins.detected.imports ++ unit.definitions.dslDefinitions.imports

View File

@ -0,0 +1,17 @@
package sbt
// Todo share this this io.syntax
private[sbt] trait IOSyntax0 extends IOSyntax1 {
implicit def alternative[A, B](f: A => Option[B]): Alternative[A, B] =
new Alternative[A, B] {
def |(g: A => Option[B]) =
(a: A) => f(a) orElse g(a)
}
}
private[sbt] trait Alternative[A, B] {
def |(g: A => Option[B]): A => Option[B]
}
private[sbt] trait IOSyntax1 {
implicit def singleFileFinder(file: File): sbt.io.PathFinder = sbt.io.PathFinder(file)
}

View File

@ -1,4 +1,48 @@
/* sbt -- Simple Build Tool
* Copyright 2010, 2011 Mark Harrah
*/
package object sbt extends Import
package object sbt extends sbt.IOSyntax0
with sbt.std.TaskExtra
with sbt.internal.util.Types
with sbt.internal.librarymanagement.impl.DependencyBuilders
with sbt.ProjectExtra
with sbt.internal.librarymanagement.DependencyFilterExtra
with sbt.BuildExtra
with sbt.TaskMacroExtra
with sbt.ScopeFilter.Make
with sbt.BuildSyntax
with sbt.Import {
// IO
def uri(s: String): URI = new URI(s)
def file(s: String): File = new File(s)
def url(s: String): URL = new URL(s)
implicit def fileToRichFile(file: File): sbt.io.RichFile = new sbt.io.RichFile(file)
implicit def filesToFinder(cc: Traversable[File]): sbt.io.PathFinder = sbt.io.PathFinder.strict(cc)
// others
object CompileOrder {
val JavaThenScala = xsbti.compile.CompileOrder.JavaThenScala
val ScalaThenJava = xsbti.compile.CompileOrder.ScalaThenJava
val Mixed = xsbti.compile.CompileOrder.Mixed
}
type CompileOrder = xsbti.compile.CompileOrder
implicit def maybeToOption[S](m: xsbti.Maybe[S]): Option[S] =
if (m.isDefined) Some(m.get) else None
final val ThisScope = Scope.ThisScope
final val GlobalScope = Scope.GlobalScope
import sbt.{ Configurations => C }
final val Compile = C.Compile
final val Test = C.Test
final val Runtime = C.Runtime
final val IntegrationTest = C.IntegrationTest
final val Default = C.Default
final val Provided = C.Provided
// java.lang.System is more important, so don't alias this one
// final val System = C.System
final val Optional = C.Optional
def config(s: String): Configuration = C.config(s)
}

View File

@ -1,60 +0,0 @@
package sbt
object syntax extends syntax
abstract class syntax extends IOSyntax0 with sbt.std.TaskExtra with sbt.internal.util.Types
with sbt.internal.librarymanagement.impl.DependencyBuilders with sbt.ProjectExtra
with sbt.internal.librarymanagement.DependencyFilterExtra with sbt.BuildExtra with sbt.TaskMacroExtra
with sbt.ScopeFilter.Make
with sbt.BuildSyntax {
// IO
def uri(s: String): URI = new URI(s)
def file(s: String): File = new File(s)
def url(s: String): URL = new URL(s)
implicit def fileToRichFile(file: File): sbt.io.RichFile = new sbt.io.RichFile(file)
implicit def filesToFinder(cc: Traversable[File]): sbt.io.PathFinder = sbt.io.PathFinder.strict(cc)
// others
object CompileOrder {
val JavaThenScala = xsbti.compile.CompileOrder.JavaThenScala
val ScalaThenJava = xsbti.compile.CompileOrder.ScalaThenJava
val Mixed = xsbti.compile.CompileOrder.Mixed
}
type CompileOrder = xsbti.compile.CompileOrder
implicit def maybeToOption[S](m: xsbti.Maybe[S]): Option[S] =
if (m.isDefined) Some(m.get) else None
final val ThisScope = Scope.ThisScope
final val GlobalScope = Scope.GlobalScope
import sbt.{ Configurations => C }
final val Compile = C.Compile
final val Test = C.Test
final val Runtime = C.Runtime
final val IntegrationTest = C.IntegrationTest
final val Default = C.Default
final val Provided = C.Provided
// java.lang.System is more important, so don't alias this one
// final val System = C.System
final val Optional = C.Optional
def config(s: String): Configuration = C.config(s)
}
// Todo share this this io.syntax
private[sbt] trait IOSyntax0 extends IOSyntax1 {
implicit def alternative[A, B](f: A => Option[B]): Alternative[A, B] =
new Alternative[A, B] {
def |(g: A => Option[B]) =
(a: A) => f(a) orElse g(a)
}
}
private[sbt] trait Alternative[A, B] {
def |(g: A => Option[B]): A => Option[B]
}
private[sbt] trait IOSyntax1 {
implicit def singleFileFinder(file: File): sbt.io.PathFinder = sbt.io.PathFinder(file)
}

View File

@ -1,4 +1,4 @@
import sbt._, syntax._, Keys._
import sbt._, Keys._
import Def.Initialize
object Marker extends AutoPlugin {

View File

@ -1,4 +1,4 @@
import sbt._, syntax._, Keys._
import sbt._, Keys._
import Def.Initialize
import complete.{DefaultParsers, Parser}

View File

@ -1,4 +1,4 @@
import sbt._, syntax._, Keys._
import sbt._, Keys._
import Def.Initialize
import complete.{DefaultParsers, Parser}

View File

@ -1,5 +1,4 @@
import sbt._
import syntax._
object FooPlugin extends AutoPlugin {
override def trigger = noTrigger

View File

@ -1,6 +1,5 @@
package sbt
import sbt.syntax._
import sbt.Keys._
import xsbti.{Position, Severity}

View File

@ -1,4 +1,4 @@
import sbt._, syntax._
import sbt._
object Q extends AutoPlugin {
override val requires = plugins.JvmPlugin

View File

@ -1,4 +1,4 @@
import sbt._, syntax._, Keys._
import sbt._, Keys._
object TestP extends AutoPlugin {
override def projectSettings: Seq[Setting[_]] = Seq(

View File

@ -1,5 +1,5 @@
package sbttest
import sbt._, syntax._, Keys._
import sbt._, Keys._
object Imports {
object A extends AutoPlugin

View File

@ -1,7 +1,7 @@
// no package
// plugins declared within no package should be visible to other plugins in the _root_ package
import sbt._, syntax._, Keys._
import sbt._, Keys._
object TopLevelImports {
lazy val topLevelDemo = settingKey[String]("A top level demo setting.")

View File

@ -1,6 +1,6 @@
package sbttest // you need package http://stackoverflow.com/questions/9822008/
import sbt._, syntax._, Keys._
import sbt._, Keys._
import java.util.concurrent.atomic.{AtomicInteger => AInt}
object A extends AutoPlugin { override def requires: Plugins = empty }

View File

@ -1,6 +1,6 @@
package sbttest // you need package http://stackoverflow.com/questions/9822008/
import sbt._, syntax._, Keys._
import sbt._, Keys._
object C extends AutoPlugin {
object autoImport {

View File

@ -1,6 +1,6 @@
// no package declaration
import sbt._, syntax._, Keys._
import sbt._, Keys._
object D extends AutoPlugin {
object autoImport {

View File

@ -1,4 +1,4 @@
import sbt._, syntax._, Keys._
import sbt._, Keys._
object DatabasePlugin extends AutoPlugin {
override def requires: Plugins = sbt.plugins.JvmPlugin

View File

@ -1,4 +1,4 @@
import sbt._, syntax._, Keys._
import sbt._, Keys._
object ExtraProjectPluginExample extends AutoPlugin {
override def extraProjects: Seq[Project] =

View File

@ -1,4 +1,4 @@
import sbt._, syntax._, Keys._
import sbt._, Keys._
object ExtraProjectPluginExample2 extends AutoPlugin {
// Enable this plugin by default

View File

@ -1,6 +1,6 @@
package test
import sbt._, syntax._, Keys._
import sbt._, Keys._
object Global {
val x = 3

View File

@ -1,4 +1,4 @@
lazy val project = (sbt.syntax.project in file(".")).
lazy val project = (sbt.project in file(".")).
settings(
name := "project",
scalaVersion := "2.11.7",

View File

@ -1,4 +1,4 @@
import sbt._, syntax._, Keys._
import sbt._, Keys._
import sbt.internal.SessionSettings

View File

@ -10,8 +10,6 @@ import sbt.internal.inc.classpath.ClasspathUtilities
import sbt.internal.inc.ModuleUtilities
import java.lang.reflect.Method
import sbt.syntax._
object ScriptedPlugin extends AutoPlugin {
override def requires = plugins.JvmPlugin
override def trigger = allRequirements