Skip to content

Commit

Permalink
Merge pull request sbt#7105 from eed3si9n/wip/merge-1.9.x
Browse files Browse the repository at this point in the history
Merge 1.9.x into develop branch
  • Loading branch information
eed3si9n authored Jan 2, 2023
2 parents e8c58df + bb40e1b commit 1d027ec
Show file tree
Hide file tree
Showing 52 changed files with 222 additions and 66 deletions.
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE/--feature-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ assignees: ''

---

Please use https://github.com/sbt/sbt/discussions including a specific user story instead of posting them to the issue tracker.
If you have new ideas about sbt or an open-ended discussion, please use https://github.com/sbt/sbt/discussions instead of posting them to the issue tracker, which we use to track bugs and (internal) todo list.

Please note that sbt is mostly maintained by community effort, so one of the questions that we'd ask might be "would like to contribute it if we help you where the relevant code is".
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on:
pull_request:
push:

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
test:
strategy:
Expand Down Expand Up @@ -41,15 +44,15 @@ jobs:
java: 8
distribution: adopt
jobtype: 8
- os: windows-2019
- os: windows-latest
java: 8
distribution: adopt
jobtype: 9
runs-on: ${{ matrix.os }}
env:
JAVA_OPTS: -Xms800M -Xmx2G -Xss6M -XX:ReservedCodeCacheSize=128M -server -Dsbt.io.virtual=false -Dfile.encoding=UTF-8
JVM_OPTS: -Xms800M -Xmx2G -Xss6M -XX:ReservedCodeCacheSize=128M -server -Dsbt.io.virtual=false -Dfile.encoding=UTF-8
SCALA_212: 2.12.16
SCALA_212: 2.12.17
SCALA_213: 2.13.8
SCALA_3: 3.1.0
UTIL_TESTS: "utilCache/test utilControl/test utilInterface/test utilLogging/test utilPosition/test utilRelation/test utilScripted/test utilTracking/test"
Expand Down Expand Up @@ -97,11 +100,12 @@ jobs:
key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
- name: Setup Windows C++ toolchain
uses: ilammy/msvc-dev-cmd@v1
if: ${{ matrix.os == 'windows-2019' }}
if: ${{ matrix.os == 'windows-latest' }}
- name: Build and test (1)
if: ${{ matrix.jobtype == 1 }}
shell: bash
run: |
rm -rf "$HOME/.sbt/boot/" || true
# ./sbt -v --client mimaReportBinaryIssues
./sbt -v --client javafmtCheck
./sbt -v --client "Test/javafmtCheck"
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/dependency-graph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ name: Submit Dependency Graph
on:
push:
branches: [1.7.x] # default branch of the project
permissions: {}
jobs:
submit-graph:
permissions:
contents: write # to submit the dependency graph

name: Submit Dependency Graph
runs-on: ubuntu-latest # or windows-latest, or macOS-latest
steps:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
# # 08:00 UTC = 03:00 EST
# - cron: '0 8 * * *'

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
deploy:
strategy:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ npm-debug.log
.vscode/
metals.sbt
launcher-package/citest/freshly-baked
.vscode
11 changes: 7 additions & 4 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ Create a [fork](https://docs.github.com/en/github/getting-started-with-github/fo

### Branch to work against

sbt uses two branches for development:
sbt uses **two or three** branches for development:
Generally the default branch set on Github is what we recommend as the base line for PRs.

- Development branch: `develop` (this is also called "master")
- Stable branch: `1.$MINOR.x`, where `$MINOR` is current minor version (e.g. `1.1.x` during 1.1.x series)
- Next minor branch: `1.$MINOR.x`, where `$MINOR` is next minor version (e.g. `1.9.x` during 1.8.x series)
- Development branch: `develop`
- Stable branch: `1.$MINOR.x`, where `$MINOR` is current minor version (e.g. `1.8.x` during 1.8.x series)

The `develop` branch represents the next major version of sbt. Only new features are pushed to the `develop` branch. This is the branch that you will branch off of to make your changes.
Currently `develop` branch represents the next major version of sbt, i.e. sbt 2.
Next minor branch is where new features can be added as long as it is binary compatible with sbt 1.0.
The `stable` branch represents the current stable sbt release. Only bug fixes are back-ported to the stable branch.

### Instruction to build just sbt
Expand Down
5 changes: 3 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import scala.util.Try
// ThisBuild settings take lower precedence,
// but can be shared across the multi projects.
ThisBuild / version := {
val v = "1.7.2-SNAPSHOT"
val v = "1.8.1-SNAPSHOT"
nightlyVersion.getOrElse(v)
}
ThisBuild / version2_13 := "2.0.0-SNAPSHOT"
Expand Down Expand Up @@ -43,10 +43,11 @@ ThisBuild / scmInfo := Some(
ScmInfo(url("https://github.com/sbt/sbt"), "[email protected]:sbt/sbt.git")
)
ThisBuild / resolvers += Resolver.mavenLocal
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always

Global / semanticdbEnabled := !(Global / insideCI).value
// Change main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala too, if you change this.
Global / semanticdbVersion := "4.5.9"
Global / semanticdbVersion := "4.5.13"
val excludeLint = SettingKey[Set[Def.KeyedInitialize[_]]]("excludeLintKeys")
Global / excludeLint := (Global / excludeLint).?.value.getOrElse(Set.empty)
Global / excludeLint += componentID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,12 @@ object ConsoleAppender {
def out: ConsoleOut
}
private[sbt] object Properties {
def from(terminal: Terminal): Properties = new Properties {
override def isAnsiSupported: Boolean = terminal.isAnsiSupported
override def isColorEnabled: Boolean = terminal.isColorEnabled
override def out = ConsoleOut.terminalOut(terminal)
}
def from(terminal: Terminal): Properties =
from(ConsoleOut.terminalOut(terminal), terminal.isAnsiSupported, terminal.isColorEnabled)

def safelyFrom(terminal: Terminal): Properties =
from(ConsoleOut.safeTerminalOut(terminal), terminal.isAnsiSupported, terminal.isColorEnabled)

def from(o: ConsoleOut, ansi: Boolean, color: Boolean): Properties = new Properties {
override def isAnsiSupported: Boolean = ansi
override def isColorEnabled: Boolean = color
Expand Down Expand Up @@ -246,6 +247,18 @@ object ConsoleAppender {
new ConsoleAppender(name, Properties.from(terminal), noSuppressedMessage)
}

/**
* A new `ConsoleAppender` identified by `name`, and that writes to `terminal`.
* Printing to this Appender will not throw if the Terminal has been closed.
*
* @param name An identifier for the `ConsoleAppender`.
* @param terminal The terminal to which this appender corresponds
* @return A new `ConsoleAppender` that writes to `terminal`.
*/
def safe(name: String, terminal: Terminal): Appender = {
new ConsoleAppender(name, Properties.safelyFrom(terminal), noSuppressedMessage)
}

/**
* A new `ConsoleAppender` identified by `name`, and that writes to `out`.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package sbt.internal.util

import java.io.{ BufferedWriter, PrintStream, PrintWriter }
import java.nio.channels.ClosedChannelException
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicReference

Expand Down Expand Up @@ -90,6 +91,26 @@ object ConsoleOut {
override def toString: String = s"TerminalOut"
}

/** Same as terminalOut but it catches and ignores the ClosedChannelException
*/
def safeTerminalOut(terminal: Terminal): ConsoleOut = {
val out = terminalOut(terminal)
new ConsoleOut {
override val lockObject: AnyRef = terminal
override def print(s: String): Unit = catchException(out.print(s))
override def println(s: String): Unit = catchException(out.println(s))
override def println(): Unit = catchException(out.println())
override def flush(): Unit = catchException(out.flush)
override def toString: String = s"SafeTerminalOut($terminal)"
private def catchException(f: => Unit): Unit = {
try f
catch {
case _: ClosedChannelException => ()
}
}
}
}

private[this] val consoleOutPerTerminal = new ConcurrentHashMap[Terminal, ConsoleOut]
def terminalOut(terminal: Terminal): ConsoleOut = consoleOutPerTerminal.get(terminal) match {
case null =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ object Terminal {
override def toString: String = s"ProxyTerminal(current = $t)"
}
private[sbt] def get: Terminal = ProxyTerminal
private[sbt] def current: Terminal = activeTerminal.get

private[sbt] def withIn[T](in: InputStream)(f: => T): T = {
val original = inputStream.get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ object LoggerContext {
}
}
def close(): Unit = {
loggers.forEach((name, l) => l.clearAppenders())
closed.set(true)
loggers.forEach((_, l) => l.clearAppenders())
loggers.clear()
}
}
Expand Down
2 changes: 1 addition & 1 deletion main/src/main/scala/sbt/Defaults.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ object Defaults extends BuildCommon {
Seq(
testFrameworks :== {
import sbt.TestFrameworks._
Seq(ScalaCheck, Specs2, Specs, ScalaTest, JUnit, MUnit)
Seq(ScalaCheck, Specs2, Specs, ScalaTest, JUnit, MUnit, ZIOTest)
},
testListeners :== Nil,
testOptions :== Nil,
Expand Down
2 changes: 1 addition & 1 deletion main/src/main/scala/sbt/PluginCross.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private[sbt] object PluginCross {
VersionNumber(sv) match {
case VersionNumber(Seq(0, 12, _*), _, _) => "2.9.2"
case VersionNumber(Seq(0, 13, _*), _, _) => "2.10.7"
case VersionNumber(Seq(1, 0, _*), _, _) => "2.12.16"
case VersionNumber(Seq(1, 0, _*), _, _) => "2.12.17"
case _ => sys.error(s"Unsupported sbt binary version: $sv")
}
}
1 change: 1 addition & 0 deletions main/src/main/scala/sbt/coursierint/LMCoursier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import lmcoursier.definitions.{
Strict => CStrict,
}
import lmcoursier._
import lmcoursier.syntax._
import lmcoursier.credentials.Credentials
import Keys._
import sbt.internal.util.Util
Expand Down
15 changes: 4 additions & 11 deletions main/src/main/scala/sbt/internal/DefaultBackgroundJobService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ private[sbt] abstract class AbstractJobHandle extends JobHandle {
private[sbt] abstract class AbstractBackgroundJobService extends BackgroundJobService {
private val nextId = new AtomicLong(1)
private val pool = new BackgroundThreadPool()
private val context = LoggerContext()

private[sbt] def serviceTempDirBase: File
private[sbt] def useLog4J: Boolean
Expand All @@ -90,7 +91,6 @@ private[sbt] abstract class AbstractBackgroundJobService extends BackgroundJobSe
// hooks for sending start/stop events
protected def onAddJob(@deprecated("unused", "") job: JobHandle): Unit = ()
protected def onRemoveJob(@deprecated("unused", "") job: JobHandle): Unit = ()
private val context = LoggerContext()

// this mutable state could conceptually go on State except
// that then every task that runs a background job would have
Expand Down Expand Up @@ -122,12 +122,9 @@ private[sbt] abstract class AbstractBackgroundJobService extends BackgroundJobSe
def humanReadableName: String = job.humanReadableName

job.onStop { () =>
// TODO: Fix this
// logger.close()
removeJob(this)
IO.delete(workingDirectory)
context.clearAppenders(logger.name)
context.close()
}
addJob(this)
override final def equals(other: Any): Boolean = other match {
Expand All @@ -144,15 +141,15 @@ private[sbt] abstract class AbstractBackgroundJobService extends BackgroundJobSe
override val spawningTask: ScopedKey[_] = unknownTask
}

protected def makeContext(id: Long, spawningTask: ScopedKey[_], state: State): ManagedLogger

def doRunInBackground(
spawningTask: ScopedKey[_],
state: State,
start: (Logger, File) => BackgroundJob
): JobHandle = {
val id = nextId.getAndIncrement()
val logger = makeContext(id, spawningTask, state)
val extracted = Project.extract(state)
val logger =
LogManager.constructBackgroundLog(extracted.structure.data, state, context)(spawningTask)
val workingDir = serviceTempDir / s"job-$id"
IO.createDirectory(workingDir)
val job = try {
Expand Down Expand Up @@ -502,10 +499,6 @@ private[sbt] class DefaultBackgroundJobService(
) extends AbstractBackgroundJobService {
@deprecated("Use the constructor that specifies the background job temporary directory", "1.4.0")
def this() = this(IO.createTemporaryDirectory, false)
override def makeContext(id: Long, spawningTask: ScopedKey[_], state: State): ManagedLogger = {
val extracted = Project.extract(state)
LogManager.constructBackgroundLog(extracted.structure.data, state)(spawningTask)
}
}
private[sbt] object DefaultBackgroundJobService {

Expand Down
14 changes: 11 additions & 3 deletions main/src/main/scala/sbt/internal/LogManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,23 @@ object LogManager {
manager(data, state, task, to, context)
}

@nowarn
@deprecated("Use alternate constructBackgroundLog that provides a LoggerContext", "1.8.0")
def constructBackgroundLog(
data: Settings[Scope],
state: State
): ScopedKey[_] => ManagedLogger = {
val context = state.get(Keys.loggerContext).getOrElse(LoggerContext.globalContext)
constructBackgroundLog(data, state, context)
}

def constructBackgroundLog(
data: Settings[Scope],
state: State,
context: LoggerContext
): (ScopedKey[_]) => ManagedLogger =
(task: ScopedKey[_]) => {
val manager: LogManager =
(logManager in task.scope).get(data) getOrElse defaultManager(state.globalLogging.console)
val context = state.get(Keys.loggerContext).getOrElse(LoggerContext.globalContext)
manager.backgroundLog(data, state, task, context)
}

Expand Down Expand Up @@ -134,7 +142,7 @@ object LogManager {
task: ScopedKey[_],
context: LoggerContext
): ManagedLogger = {
val console = screen(task, state)
val console = ConsoleAppender.safe("bg-" + ConsoleAppender.generateName(), ITerminal.current)
LogManager.backgroundLog(data, state, task, console, relay(()), context)
}
}
Expand Down
13 changes: 11 additions & 2 deletions main/src/main/scala/sbt/internal/SysProp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import java.util.Locale

import scala.util.control.NonFatal
import scala.concurrent.duration._
import sbt.internal.inc.HashUtil
import sbt.internal.util.{ Terminal => ITerminal, Util }
import sbt.internal.util.complete.SizeParser
import sbt.io.syntax._
Expand Down Expand Up @@ -247,7 +248,15 @@ object SysProp {
* Windows, and Docker environment.
* Mostly these directories will be used as throw-away location to extract
* native files etc.
* A deterministic hash is appended in the directory name as "/tmp/.sbt1234ABCD/"
* to avoid collision between multiple users in a shared server environment.
*/
private[this] def runtimeDirectory: Path =
Paths.get(sys.env.getOrElse("XDG_RUNTIME_DIR", sys.props("java.io.tmpdir"))).resolve(".sbt")
private[this] def runtimeDirectory: Path = {
val hashValue =
java.lang.Long.toHexString(HashUtil.farmHash(home.toString.getBytes("UTF-8")))
val halfhash = hashValue.take(8)
Paths
.get(sys.env.getOrElse("XDG_RUNTIME_DIR", sys.props("java.io.tmpdir")))
.resolve(s".sbt$halfhash")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ final class BuildServerReporterImpl(
Diagnostic(
range,
Option(toDiagnosticSeverity(problem.severity)),
None,
problem.diagnosticCode().toOption.map(_.code),
Option("sbt"),
problem.message
)
Expand Down
2 changes: 1 addition & 1 deletion main/src/main/scala/sbt/plugins/Giter8TemplatePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object Giter8TemplatePlugin extends AutoPlugin {
ModuleID(
"org.scala-sbt.sbt-giter8-resolver",
"sbt-giter8-resolver",
"0.13.1"
"0.15.0"
) cross CrossVersion.binary,
"sbtgiter8resolver.Giter8TemplateResolver"
)
Expand Down
2 changes: 1 addition & 1 deletion main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object SemanticdbPlugin extends AutoPlugin {
semanticdbEnabled := SysProp.semanticdb,
semanticdbIncludeInJar := false,
semanticdbOptions := List(),
semanticdbVersion := "4.5.9"
semanticdbVersion := "4.5.13"
)

override lazy val projectSettings: Seq[Def.Setting[_]] = Seq(
Expand Down
Loading

0 comments on commit 1d027ec

Please sign in to comment.