Merge pull request #6288 from eed3si9n/bport/1.4.x

[1.4.x] Various backports
This commit is contained in:
eugene yokota 2021-01-30 13:33:39 -05:00 committed by GitHub
commit fede746922
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 44 additions and 11 deletions

1
.gitignore vendored
View File

@ -10,4 +10,5 @@ npm-debug.log
.idea .idea
.bloop .bloop
.metals .metals
.bsp/
/project/metals.sbt /project/metals.sbt

View File

@ -157,7 +157,7 @@ final class ContextUtil[C <: blackbox.Context](val ctx: C) {
case _ => () case _ => ()
} }
@deprecated("1.3.0", "Use that variant that specifies the M instance types to exclude") @deprecated("Use that variant that specifies the M instance types to exclude", since = "1.3.0")
/** /**
* A function that checks the provided tree for illegal references to M instances defined in the * A function that checks the provided tree for illegal references to M instances defined in the
* expression passed to the macro and for illegal dereferencing of M instances. * expression passed to the macro and for illegal dereferencing of M instances.

View File

@ -64,6 +64,8 @@ object Util {
lazy val isNonCygwinWindows: Boolean = isWindows && !isCygwin lazy val isNonCygwinWindows: Boolean = isWindows && !isCygwin
lazy val isCygwinWindows: Boolean = isWindows && isCygwin lazy val isCygwinWindows: Boolean = isWindows && isCygwin
lazy val isEmacs: Boolean = Option(System.getenv("INSIDE_EMACS")).isDefined
def nil[A]: List[A] = List.empty[A] def nil[A]: List[A] = List.empty[A]
def nilSeq[A]: Seq[A] = Seq.empty[A] def nilSeq[A]: Seq[A] = Seq.empty[A]
def none[A]: Option[A] = (None: Option[A]) def none[A]: Option[A] = (None: Option[A])

View File

@ -63,11 +63,14 @@ object LineReader {
* `testOnly testOnly\ com.foo.FooSpec` instead of `testOnly com.foo.FooSpec`. * `testOnly testOnly\ com.foo.FooSpec` instead of `testOnly com.foo.FooSpec`.
*/ */
if (c.append.nonEmpty) { if (c.append.nonEmpty) {
if (!pl.line().endsWith(" ")) { val cand = pl.line() match {
candidates.add(new Candidate(pl.line().split(" ").last + c.append)) case line if line.endsWith(" ") => c.append
} else { case line => line.split(" ").last + c.append
candidates.add(new Candidate(c.append))
} }
// https://github.com/jline/jline3/blob/9a4971868e4bdd29a36e454de01f54d3cd6071e0/reader/src/main/java/org/jline/reader/Candidate.java#L123-L131
// "If the candidate is complete and is selected, a space separator will be added."
val complete = false
candidates.add(new Candidate(cand, cand, null, null, null, null, complete))
} }
} }
} }

View File

@ -317,7 +317,10 @@ object Terminal {
props props
.map(_.color) .map(_.color)
.orElse(isColorEnabledProp) .orElse(isColorEnabledProp)
.getOrElse(logFormatEnabled.getOrElse(true) && ((hasConsole && !isDumbTerminal) || isCI)) .getOrElse(
logFormatEnabled
.getOrElse(true) && ((hasConsole && !isDumbTerminal) || isCI || Util.isEmacs)
)
} }
private[this] lazy val isColorEnabledProp: Option[Boolean] = private[this] lazy val isColorEnabledProp: Option[Boolean] =
sys.props.get("sbt.color").orElse(sys.props.get("sbt.colour")).flatMap(parseLogOption) sys.props.get("sbt.color").orElse(sys.props.get("sbt.colour")).flatMap(parseLogOption)
@ -867,7 +870,8 @@ object Terminal {
.map(_.supershell) .map(_.supershell)
.getOrElse(System.getProperty("sbt.supershell") match { .getOrElse(System.getProperty("sbt.supershell") match {
case null => case null =>
!(sys.env.contains("BUILD_NUMBER") || sys.env.contains("CI")) && isColorEnabled !(sys.env.contains("BUILD_NUMBER") || sys.env
.contains("CI")) && isColorEnabled && !Util.isEmacs
case "true" => true case "true" => true
case _ => false case _ => false
}) })

View File

@ -330,8 +330,14 @@ class NetworkClient(
val cmd = List(arguments.sbtScript) ++ arguments.sbtArguments ++ val cmd = List(arguments.sbtScript) ++ arguments.sbtArguments ++
List(BasicCommandStrings.DashDashDetachStdio, BasicCommandStrings.DashDashServer) List(BasicCommandStrings.DashDashDetachStdio, BasicCommandStrings.DashDashServer)
// https://github.com/sbt/sbt/issues/6271
val nohup =
if (Util.isEmacs && !Util.isWindows) List("nohup")
else Nil
val processBuilder = val processBuilder =
new ProcessBuilder(cmd: _*) new ProcessBuilder((nohup ++ cmd): _*)
.directory(arguments.baseDirectory) .directory(arguments.baseDirectory)
.redirectInput(Redirect.PIPE) .redirectInput(Redirect.PIPE)
processBuilder.environment.put(Terminal.TERMINAL_PROPS, props) processBuilder.environment.put(Terminal.TERMINAL_PROPS, props)

View File

@ -4175,6 +4175,10 @@ trait BuildExtra extends BuildCommon with DefExtra {
baseDirectory.value / name baseDirectory.value / name
} }
@deprecated(
"externalIvyFile is not supported by Couriser, and will be removed in the future",
since = "1.5.0"
)
def externalIvyFile( def externalIvyFile(
file: Initialize[File] = inBase("ivy.xml"), file: Initialize[File] = inBase("ivy.xml"),
iScala: Initialize[Option[ScalaModuleInfo]] = scalaModuleInfo iScala: Initialize[Option[ScalaModuleInfo]] = scalaModuleInfo
@ -4186,6 +4190,10 @@ trait BuildExtra extends BuildCommon with DefExtra {
managedScalaInstance.value managedScalaInstance.value
) )
@deprecated(
"externalPom is not supported by Coursier, and will be removed in the future",
since = "1.5.0"
)
def externalPom( def externalPom(
file: Initialize[File] = inBase("pom.xml"), file: Initialize[File] = inBase("pom.xml"),
iScala: Initialize[Option[ScalaModuleInfo]] = scalaModuleInfo, iScala: Initialize[Option[ScalaModuleInfo]] = scalaModuleInfo,

View File

@ -8,6 +8,7 @@
package sbt package sbt
import java.io.PrintWriter import java.io.PrintWriter
import java.util.concurrent.RejectedExecutionException
import java.util.Properties import java.util.Properties
import sbt.BasicCommandStrings.{ StashOnFailure, networkExecPrefix } import sbt.BasicCommandStrings.{ StashOnFailure, networkExecPrefix }
@ -240,6 +241,13 @@ object MainLoop {
FastTrackCommands FastTrackCommands
.evaluate(termState, exec.commandLine) .evaluate(termState, exec.commandLine)
.getOrElse(Command.process(exec.commandLine, termState)) .getOrElse(Command.process(exec.commandLine, termState))
} catch {
case _: RejectedExecutionException =>
// No stack trace since this is just to notify the user which command they cancelled
object Cancelled extends Throwable(exec.commandLine, null, true, false) {
override def toString: String = s"Cancelled: ${exec.commandLine}"
}
throw Cancelled
} finally { } finally {
// Flush the terminal output after command evaluation to ensure that all output // Flush the terminal output after command evaluation to ensure that all output
// is displayed in the thin client before we report the command status. Also // is displayed in the thin client before we report the command status. Also
@ -328,5 +336,4 @@ object MainLoop {
if (prevState.onFailure.isDefined && state.onFailure.isEmpty && if (prevState.onFailure.isDefined && state.onFailure.isEmpty &&
state.currentCommand.fold(true)(_ != StashOnFailure)) ExitCode(ErrorCodes.UnknownError) state.currentCommand.fold(true)(_ != StashOnFailure)) ExitCode(ErrorCodes.UnknownError)
else ExitCode.Success else ExitCode.Success
} }

View File

@ -77,7 +77,7 @@ object Dependencies {
def addSbtZincCompile = addSbtModule(sbtZincPath, "zincCompileJVM2_12", zincCompile) def addSbtZincCompile = addSbtModule(sbtZincPath, "zincCompileJVM2_12", zincCompile)
def addSbtZincCompileCore = addSbtModule(sbtZincPath, "zincCompileCoreJVM2_12", zincCompileCore) def addSbtZincCompileCore = addSbtModule(sbtZincPath, "zincCompileCoreJVM2_12", zincCompileCore)
val lmCoursierShaded = "io.get-coursier" %% "lm-coursier-shaded" % "2.0.5" val lmCoursierShaded = "io.get-coursier" %% "lm-coursier-shaded" % "2.0.6"
def sjsonNew(n: String) = def sjsonNew(n: String) =
Def.setting("com.eed3si9n" %% n % "0.9.1") // contrabandSjsonNewVersion.value Def.setting("com.eed3si9n" %% n % "0.9.1") // contrabandSjsonNewVersion.value

View File

@ -305,7 +305,9 @@ object ConcurrentRestrictions {
def take(): R = { def take(): R = {
if (closed.get) if (closed.get)
throw new IllegalStateException("Tried to get values for a closed completion service") throw new RejectedExecutionException(
"Tried to get values for a closed completion service"
)
jservice.take().get() jservice.take().get()
} }
} }