mirror of https://github.com/sbt/sbt.git
Fix scala 2 compat with -Xsource:3 and scala-collection-compat
This commit is contained in:
parent
0458e8063d
commit
369e647008
34
build.sbt
34
build.sbt
|
|
@ -55,7 +55,7 @@ Global / excludeLint += scriptedBufferLog
|
||||||
Global / excludeLint += checkPluginCross
|
Global / excludeLint += checkPluginCross
|
||||||
ThisBuild / evictionErrorLevel := Level.Info
|
ThisBuild / evictionErrorLevel := Level.Info
|
||||||
|
|
||||||
def commonBaseSettings: Seq[Setting[_]] = Def.settings(
|
def commonSettings: Seq[Setting[_]] = Def.settings(
|
||||||
headerLicense := Some(
|
headerLicense := Some(
|
||||||
HeaderLicense.Custom(
|
HeaderLicense.Custom(
|
||||||
"""|sbt
|
"""|sbt
|
||||||
|
|
@ -68,7 +68,7 @@ def commonBaseSettings: Seq[Setting[_]] = Def.settings(
|
||||||
scalaVersion := baseScalaVersion,
|
scalaVersion := baseScalaVersion,
|
||||||
componentID := None,
|
componentID := None,
|
||||||
resolvers += Resolver.typesafeIvyRepo("releases").withName("typesafe-sbt-build-ivy-releases"),
|
resolvers += Resolver.typesafeIvyRepo("releases").withName("typesafe-sbt-build-ivy-releases"),
|
||||||
resolvers += Resolver.sonatypeRepo("snapshots"),
|
resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
|
||||||
testFrameworks += TestFramework("hedgehog.sbt.Framework"),
|
testFrameworks += TestFramework("hedgehog.sbt.Framework"),
|
||||||
testFrameworks += TestFramework("verify.runner.Framework"),
|
testFrameworks += TestFramework("verify.runner.Framework"),
|
||||||
Global / concurrentRestrictions += Util.testExclusiveRestriction,
|
Global / concurrentRestrictions += Util.testExclusiveRestriction,
|
||||||
|
|
@ -101,20 +101,15 @@ def commonBaseSettings: Seq[Setting[_]] = Def.settings(
|
||||||
Test / publishArtifact := false,
|
Test / publishArtifact := false,
|
||||||
run / fork := true,
|
run / fork := true,
|
||||||
)
|
)
|
||||||
def commonSettings: Seq[Setting[_]] =
|
|
||||||
commonBaseSettings :+ {
|
|
||||||
libraryDependencies ++= {
|
|
||||||
if (scalaBinaryVersion.value == "3") {
|
|
||||||
Nil
|
|
||||||
} else {
|
|
||||||
Seq(compilerPlugin(kindProjector))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def utilCommonSettings: Seq[Setting[_]] = Def.settings(
|
def utilCommonSettings: Seq[Setting[_]] = Def.settings(
|
||||||
baseSettings,
|
baseSettings,
|
||||||
crossScalaVersions := Seq(scala212, scala213, scala3)
|
crossScalaVersions := Seq(scala212, scala213, scala3),
|
||||||
|
libraryDependencies += Dependencies.scalaCollectionCompat,
|
||||||
|
libraryDependencies ++= {
|
||||||
|
if (scalaBinaryVersion.value == "3") Nil
|
||||||
|
else Seq(compilerPlugin(kindProjector))
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
def minimalSettings: Seq[Setting[_]] =
|
def minimalSettings: Seq[Setting[_]] =
|
||||||
|
|
@ -258,12 +253,12 @@ lazy val bundledLauncherProj =
|
||||||
|
|
||||||
/* ** subproject declarations ** */
|
/* ** subproject declarations ** */
|
||||||
|
|
||||||
val collectionProj = (project in file("util-collection"))
|
val collectionProj = project
|
||||||
|
.in(file("util-collection"))
|
||||||
.dependsOn(utilPosition, utilCore)
|
.dependsOn(utilPosition, utilCore)
|
||||||
.settings(
|
.settings(
|
||||||
name := "Collections",
|
name := "Collections",
|
||||||
testedBaseSettings,
|
testedBaseSettings,
|
||||||
baseSettings,
|
|
||||||
libraryDependencies ++= Seq(sjsonNewScalaJson.value),
|
libraryDependencies ++= Seq(sjsonNewScalaJson.value),
|
||||||
libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
|
libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
|
||||||
case Some((2, major)) if major <= 12 => Seq()
|
case Some((2, major)) if major <= 12 => Seq()
|
||||||
|
|
@ -349,7 +344,8 @@ lazy val utilCore = project
|
||||||
utilMimaSettings
|
utilMimaSettings
|
||||||
)
|
)
|
||||||
|
|
||||||
lazy val utilLogging = (project in file("internal") / "util-logging")
|
lazy val utilLogging = project
|
||||||
|
.in(file("internal") / "util-logging")
|
||||||
.enablePlugins(ContrabandPlugin, JsonCodecPlugin)
|
.enablePlugins(ContrabandPlugin, JsonCodecPlugin)
|
||||||
.dependsOn(utilInterface, utilCore)
|
.dependsOn(utilInterface, utilCore)
|
||||||
.settings(
|
.settings(
|
||||||
|
|
@ -421,9 +417,9 @@ lazy val utilRelation = (project in file("internal") / "util-relation")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Persisted caching based on sjson-new
|
// Persisted caching based on sjson-new
|
||||||
lazy val utilCache = (project in file("util-cache"))
|
lazy val utilCache = project
|
||||||
|
.in(file("util-cache"))
|
||||||
.settings(
|
.settings(
|
||||||
utilCommonSettings,
|
|
||||||
testedBaseSettings,
|
testedBaseSettings,
|
||||||
name := "Util Cache",
|
name := "Util Cache",
|
||||||
libraryDependencies ++=
|
libraryDependencies ++=
|
||||||
|
|
@ -1044,7 +1040,7 @@ lazy val sbtClientProj = (project in file("client"))
|
||||||
.enablePlugins(NativeImagePlugin)
|
.enablePlugins(NativeImagePlugin)
|
||||||
.dependsOn(commandProj)
|
.dependsOn(commandProj)
|
||||||
.settings(
|
.settings(
|
||||||
commonBaseSettings,
|
commonSettings,
|
||||||
publish / skip := true,
|
publish / skip := true,
|
||||||
name := "sbt-client",
|
name := "sbt-client",
|
||||||
mimaPreviousArtifacts := Set.empty,
|
mimaPreviousArtifacts := Set.empty,
|
||||||
|
|
|
||||||
|
|
@ -373,8 +373,6 @@ object ConsoleAppender {
|
||||||
}
|
}
|
||||||
|
|
||||||
private[sbt] def generateName(): String = "out-" + generateId.incrementAndGet
|
private[sbt] def generateName(): String = "out-" + generateId.incrementAndGet
|
||||||
|
|
||||||
private[this] def ansiSupported: Boolean = Terminal.console.isAnsiSupported
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// See http://stackoverflow.com/questions/24205093/how-to-create-a-custom-appender-in-log4j2
|
// See http://stackoverflow.com/questions/24205093/how-to-create-a-custom-appender-in-log4j2
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ object ConsoleOut {
|
||||||
def systemOutOverwrite(f: (String, String) => Boolean): ConsoleOut = new ConsoleOut {
|
def systemOutOverwrite(f: (String, String) => Boolean): ConsoleOut = new ConsoleOut {
|
||||||
val lockObject: PrintStream = System.out
|
val lockObject: PrintStream = System.out
|
||||||
private[this] var last: Option[String] = None
|
private[this] var last: Option[String] = None
|
||||||
private[this] var current = new java.lang.StringBuffer
|
private[this] val current = new java.lang.StringBuffer
|
||||||
def print(s: String): Unit = synchronized { current.append(s); () }
|
def print(s: String): Unit = synchronized { current.append(s); () }
|
||||||
def println(s: String): Unit = synchronized { current.append(s); println() }
|
def println(s: String): Unit = synchronized { current.append(s); println() }
|
||||||
def println(): Unit = synchronized {
|
def println(): Unit = synchronized {
|
||||||
|
|
@ -128,7 +128,7 @@ object ConsoleOut {
|
||||||
case c => c
|
case c => c
|
||||||
}
|
}
|
||||||
def printStreamOut(out: PrintStream): ConsoleOut = new ConsoleOut {
|
def printStreamOut(out: PrintStream): ConsoleOut = new ConsoleOut {
|
||||||
val lockObject = out
|
val lockObject: AnyRef = out
|
||||||
def print(s: String) = out.print(s)
|
def print(s: String) = out.print(s)
|
||||||
def println(s: String) = out.println(s)
|
def println(s: String) = out.println(s)
|
||||||
def println() = out.println()
|
def println() = out.println()
|
||||||
|
|
@ -136,7 +136,7 @@ object ConsoleOut {
|
||||||
override def toString: String = s"PrintStreamConsoleOut($out)"
|
override def toString: String = s"PrintStreamConsoleOut($out)"
|
||||||
}
|
}
|
||||||
def printWriterOut(out: PrintWriter): ConsoleOut = new ConsoleOut {
|
def printWriterOut(out: PrintWriter): ConsoleOut = new ConsoleOut {
|
||||||
val lockObject = out
|
val lockObject: AnyRef = out
|
||||||
def print(s: String) = out.print(s)
|
def print(s: String) = out.print(s)
|
||||||
def println(s: String) = { out.println(s); flush() }
|
def println(s: String) = { out.println(s); flush() }
|
||||||
def println() = { out.println(); flush() }
|
def println() = { out.println(); flush() }
|
||||||
|
|
@ -144,7 +144,7 @@ object ConsoleOut {
|
||||||
override def toString: String = s"PrintWriterConsoleOut($out)"
|
override def toString: String = s"PrintWriterConsoleOut($out)"
|
||||||
}
|
}
|
||||||
def bufferedWriterOut(out: BufferedWriter): ConsoleOut = new ConsoleOut {
|
def bufferedWriterOut(out: BufferedWriter): ConsoleOut = new ConsoleOut {
|
||||||
val lockObject = out
|
val lockObject: AnyRef = out
|
||||||
def print(s: String) = out.write(s)
|
def print(s: String) = out.write(s)
|
||||||
def println(s: String) = { out.write(s); println() }
|
def println(s: String) = { out.write(s); println() }
|
||||||
def println() = { out.newLine(); flush() }
|
def println() = { out.newLine(); flush() }
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,6 @@ object EscHelpers {
|
||||||
*/
|
*/
|
||||||
def strip(bytes: Array[Byte], stripAnsi: Boolean, stripColor: Boolean): (Array[Byte], Int) = {
|
def strip(bytes: Array[Byte], stripAnsi: Boolean, stripColor: Boolean): (Array[Byte], Int) = {
|
||||||
val res = Array.fill[Byte](bytes.length)(0)
|
val res = Array.fill[Byte](bytes.length)(0)
|
||||||
var i = 0
|
|
||||||
var index = 0
|
var index = 0
|
||||||
var state = 0
|
var state = 0
|
||||||
var limit = 0
|
var limit = 0
|
||||||
|
|
@ -205,7 +204,6 @@ object EscHelpers {
|
||||||
def stripColorsAndMoves(s: String): String = {
|
def stripColorsAndMoves(s: String): String = {
|
||||||
val bytes = s.getBytes
|
val bytes = s.getBytes
|
||||||
val res = Array.fill[Byte](bytes.length)(0)
|
val res = Array.fill[Byte](bytes.length)(0)
|
||||||
var i = 0
|
|
||||||
var index = 0
|
var index = 0
|
||||||
var state = 0
|
var state = 0
|
||||||
var limit = 0
|
var limit = 0
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,6 @@ private[sbt] object JLine3 {
|
||||||
private[this] val forceWindowsJansiHolder = new AtomicBoolean(false)
|
private[this] val forceWindowsJansiHolder = new AtomicBoolean(false)
|
||||||
private[sbt] def forceWindowsJansi(): Unit = forceWindowsJansiHolder.set(true)
|
private[sbt] def forceWindowsJansi(): Unit = forceWindowsJansiHolder.set(true)
|
||||||
private[this] def windowsJansi(): org.jline.terminal.Terminal = {
|
private[this] def windowsJansi(): org.jline.terminal.Terminal = {
|
||||||
val support = new JansiSupportImpl
|
|
||||||
val winConsole = support.isWindowsConsole();
|
|
||||||
val termType = sys.props.get("org.jline.terminal.type").orElse(sys.env.get("TERM")).orNull
|
val termType = sys.props.get("org.jline.terminal.type").orElse(sys.env.get("TERM")).orNull
|
||||||
val term = JansiWinSysTerminal.createTerminal(
|
val term = JansiWinSysTerminal.createTerminal(
|
||||||
"console",
|
"console",
|
||||||
|
|
@ -220,14 +218,6 @@ private[sbt] object JLine3 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private def enterRawModeImpl(term: JTerminal): Attributes = {
|
|
||||||
val prvAttr = term.getAttributes()
|
|
||||||
val newAttr = new Attributes(prvAttr)
|
|
||||||
newAttr.setLocalFlags(EnumSet.of(LocalFlag.ICANON, LocalFlag.ECHO, LocalFlag.IEXTEN), false)
|
|
||||||
newAttr.setInputFlags(EnumSet.of(InputFlag.IXON, InputFlag.ICRNL, InputFlag.INLCR), false)
|
|
||||||
term.setAttributes(newAttr)
|
|
||||||
prvAttr
|
|
||||||
}
|
|
||||||
// We need to set the ENABLE_PROCESS_INPUT flag for ctrl+c to be treated as a signal in windows
|
// We need to set the ENABLE_PROCESS_INPUT flag for ctrl+c to be treated as a signal in windows
|
||||||
// https://docs.microsoft.com/en-us/windows/console/setconsolemode
|
// https://docs.microsoft.com/en-us/windows/console/setconsolemode
|
||||||
private[this] val ENABLE_PROCESS_INPUT = 1
|
private[this] val ENABLE_PROCESS_INPUT = 1
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ private[sbt] final class ProgressState(
|
||||||
val parts = new String(bytes, "UTF-8").split(System.lineSeparator)
|
val parts = new String(bytes, "UTF-8").split(System.lineSeparator)
|
||||||
def appendLine(l: String, appendNewline: Boolean): Unit = {
|
def appendLine(l: String, appendNewline: Boolean): Unit = {
|
||||||
toWrite ++= l.getBytes("UTF-8")
|
toWrite ++= l.getBytes("UTF-8")
|
||||||
if (!l.getBytes("UTF-8").endsWith("\r")) toWrite ++= clearScreenBytes
|
if (!l.getBytes("UTF-8").endsWith("\r".getBytes)) toWrite ++= clearScreenBytes
|
||||||
if (appendNewline) toWrite ++= lineSeparatorBytes
|
if (appendNewline) toWrite ++= lineSeparatorBytes
|
||||||
}
|
}
|
||||||
parts.dropRight(1).foreach(appendLine(_, true))
|
parts.dropRight(1).foreach(appendLine(_, true))
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
package sbt.internal.util
|
package sbt.internal.util
|
||||||
|
|
||||||
import scala.language.experimental.macros
|
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
import scala.reflect.macros.blackbox
|
import scala.reflect.macros.blackbox
|
||||||
import scala.reflect.internal.util.UndefinedPosition
|
import scala.reflect.internal.util.UndefinedPosition
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
package sbt.internal.util
|
package sbt.internal.util
|
||||||
|
|
||||||
import Relation._
|
import Relation._
|
||||||
|
import scala.collection.compat.*
|
||||||
|
|
||||||
object Relation {
|
object Relation {
|
||||||
|
|
||||||
|
|
@ -178,7 +179,7 @@ private final class MRelation[A, B](fwd: Map[A, Set[B]], rev: Map[B, Set[A]])
|
||||||
else new MRelation(add(fwd, from, to), to.foldLeft(rev)((map, t) => add(map, t, from :: Nil)))
|
else new MRelation(add(fwd, from, to), to.foldLeft(rev)((map, t) => add(map, t, from :: Nil)))
|
||||||
|
|
||||||
def ++(rs: Iterable[(A, B)]) = rs.foldLeft(this: Relation[A, B]) { _ + _ }
|
def ++(rs: Iterable[(A, B)]) = rs.foldLeft(this: Relation[A, B]) { _ + _ }
|
||||||
def ++(other: Relation[A, B]) =
|
def ++(other: Relation[A, B]): Relation[A, B] =
|
||||||
new MRelation[A, B](combine(fwd, other.forwardMap), combine(rev, other.reverseMap))
|
new MRelation[A, B](combine(fwd, other.forwardMap), combine(rev, other.reverseMap))
|
||||||
|
|
||||||
def --(ts: Iterable[A]): Relation[A, B] = ts.foldLeft(this: Relation[A, B]) { _ - _ }
|
def --(ts: Iterable[A]): Relation[A, B] = ts.foldLeft(this: Relation[A, B]) { _ - _ }
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@ package sbt
|
||||||
package internal
|
package internal
|
||||||
package scripted
|
package scripted
|
||||||
|
|
||||||
|
import java.{ util => ju }
|
||||||
|
import java.net.URL
|
||||||
|
|
||||||
final class FilteredLoader(parent: ClassLoader) extends ClassLoader(parent) {
|
final class FilteredLoader(parent: ClassLoader) extends ClassLoader(parent) {
|
||||||
@throws(classOf[ClassNotFoundException])
|
@throws(classOf[ClassNotFoundException])
|
||||||
override final def loadClass(className: String, resolve: Boolean): Class[_] = {
|
override final def loadClass(className: String, resolve: Boolean): Class[_] = {
|
||||||
|
|
@ -17,6 +20,6 @@ final class FilteredLoader(parent: ClassLoader) extends ClassLoader(parent) {
|
||||||
else
|
else
|
||||||
throw new ClassNotFoundException(className)
|
throw new ClassNotFoundException(className)
|
||||||
}
|
}
|
||||||
override def getResources(name: String) = null
|
override def getResources(name: String): ju.Enumeration[URL] = null
|
||||||
override def getResource(name: String) = null
|
override def getResource(name: String): URL = null
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,5 +29,5 @@ trait BasicStatementHandler extends StatementHandler {
|
||||||
|
|
||||||
/** Use when a stack trace is not useful */
|
/** Use when a stack trace is not useful */
|
||||||
final class TestFailed(msg: String) extends RuntimeException(msg) {
|
final class TestFailed(msg: String) extends RuntimeException(msg) {
|
||||||
override def fillInStackTrace = this
|
override def fillInStackTrace: Throwable = this
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,7 @@ object Dependencies {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
val scalaPar = "org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4"
|
val scalaPar = "org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4"
|
||||||
|
val scalaCollectionCompat = "org.scala-lang.modules" %% "scala-collection-compat" % "2.11.0"
|
||||||
|
|
||||||
// specify all of log4j modules to prevent misalignment
|
// specify all of log4j modules to prevent misalignment
|
||||||
def log4jModule = (n: String) => "org.apache.logging.log4j" % n % "2.17.1"
|
def log4jModule = (n: String) => "org.apache.logging.log4j" % n % "2.17.1"
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,8 @@ object HouseRulesPlugin extends AutoPlugin {
|
||||||
scalacOptions ++= "-Ywarn-dead-code".ifScala2.value.toList,
|
scalacOptions ++= "-Ywarn-dead-code".ifScala2.value.toList,
|
||||||
scalacOptions ++= "-Ywarn-numeric-widen".ifScala2.value.toList,
|
scalacOptions ++= "-Ywarn-numeric-widen".ifScala2.value.toList,
|
||||||
scalacOptions ++= "-Ywarn-value-discard".ifScala2.value.toList,
|
scalacOptions ++= "-Ywarn-value-discard".ifScala2.value.toList,
|
||||||
scalacOptions ++= "-Ywarn-unused-import".ifScala2x(v => 11 <= v && v <= 12).value.toList
|
scalacOptions ++= "-Ywarn-unused-import".ifScala2x(v => 11 <= v && v <= 12).value.toList,
|
||||||
|
scalacOptions ++= "-Xsource:3".ifScala2.value.toList
|
||||||
) ++ Seq(Compile, Test).flatMap(c =>
|
) ++ Seq(Compile, Test).flatMap(c =>
|
||||||
(c / console / scalacOptions) --= Seq("-Ywarn-unused-import", "-Xlint")
|
(c / console / scalacOptions) --= Seq("-Ywarn-unused-import", "-Xlint")
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,9 @@ object PublishBinPlugin extends AutoPlugin {
|
||||||
override val globalSettings = Seq(publishLocalBin := (()))
|
override val globalSettings = Seq(publishLocalBin := (()))
|
||||||
|
|
||||||
override val projectSettings: Seq[Def.Setting[_]] = Def settings (
|
override val projectSettings: Seq[Def.Setting[_]] = Def settings (
|
||||||
publishLocalBin := Classpaths.publishTask(publishLocalBinConfig).value,
|
publishLocalBin := Classpaths
|
||||||
|
.publishOrSkip(publishLocalBinConfig, publishLocalBin / skip)
|
||||||
|
.value,
|
||||||
publishLocalBinConfig := Classpaths.publishConfig(
|
publishLocalBinConfig := Classpaths.publishConfig(
|
||||||
false, // publishMavenStyle.value,
|
false, // publishMavenStyle.value,
|
||||||
Classpaths.deliverPattern(crossTarget.value),
|
Classpaths.deliverPattern(crossTarget.value),
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ object SbtLauncherPlugin extends AutoPlugin {
|
||||||
val path = dir.toPath
|
val path = dir.toPath
|
||||||
f => if (f != dir) f -> path.relativize(f.toPath).toString :: Nil else Nil
|
f => if (f != dir) f -> path.relativize(f.toPath).toString :: Nil else Nil
|
||||||
}
|
}
|
||||||
IO.zip(dir.allPaths.get().flatMap(rebase), target)
|
IO.zip(dir.allPaths.get().flatMap(rebase), target, None)
|
||||||
}
|
}
|
||||||
target
|
target
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue