Merge pull request #8237 from eed3si9n/wip/merge-1.11.x

[2.x] Merge 1.11.x
This commit is contained in:
eugene yokota 2025-08-25 03:07:15 -04:00 committed by GitHub
commit 15773d0bd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 285 additions and 144 deletions

View File

@ -36,18 +36,6 @@ jobs:
# java: 8
# distribution: zulu
# jobtype: 6
- os: ubuntu-latest
java: 8
distribution: zulu
jobtype: 7
- os: macos-latest
java: 17
distribution: temurin
jobtype: 8
- os: windows-latest
java: 8
distribution: zulu
jobtype: 9
- os: ubuntu-latest
java: 11
distribution: temurin
@ -99,22 +87,13 @@ jobs:
with:
distribution: "${{ matrix.distribution }}"
java-version: "${{ matrix.java }}"
cache: "sbt"
- name: Setup sbt
uses: sbt/setup-sbt@v1
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Coursier cache
uses: coursier/cache-action@v6
# - name: Cache sbt
# uses: actions/cache@v3
# with:
# path: ~/.sbt
# 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' }}
- name: Pre-test cleanup
shell: bash
run: |
@ -185,47 +164,6 @@ jobs:
# sbt -Dsbtzinc.path=$HOME/work/sbt/sbt/zinc -Dsbt.build.version=$BUILD_VERSION -Dsbt.build.fatal=false "+lowerUtils/publishLocal; {zinc}/publishLocal; upperModules/publishLocal"
# rm -r $(find $HOME/.sbt/boot -name "*-SNAPSHOT") || true
# sbt -v -Dsbt.version=$BUILD_VERSION "++$SCALA_213; all $UTIL_TESTS; ++$SCALA_212; all $UTIL_TESTS; scripted actions/* source-dependencies/*1of3 dependency-management/*1of4 java/*"
- name: Build and test (7)
if: ${{ matrix.jobtype == 7 }}
shell: bash
run: |
# test building sbtn on Linux
sbt "-Dsbt.io.virtual=false" nativeImage
# test launcher script
echo build using JDK 8 test using JDK 8 and JDK 11
cd launcher-package
sbt -Dsbt.build.version=$TEST_SBT_VER rpm:packageBin debian:packageBin
sbt -Dsbt.build.version=$TEST_SBT_VER integrationTest/test
cd citest && ./test.sh
$HOME/bin/jabba install $JDK11 && exec $HOME/bin/jabba which --home $JDK11
java -Xmx32m -version
./test.sh
- name: Build and test (8)
if: ${{ matrix.jobtype == 8 }}
shell: bash
run: |
# test building sbtn on macOS
./sbt "-Dsbt.io.virtual=false" nativeImage
# test launcher script
cd launcher-package
bin/coursier resolve
../sbt -Dsbt.build.version=$TEST_SBT_VER integrationTest/test
# This fails due to the JLine issue
# cd citest && ./test.sh
- name: Build and test (9)
if: ${{ matrix.jobtype == 9 }}
shell: bash
run: |
# test building sbtn on Windows
sbt "-Dsbt.io.virtual=false" nativeImage
# test launcher script
echo build using JDK 8, test using JDK 8, on Windows
cd launcher-package
bin/coursier.bat resolve
sbt -Dsbt.build.version=$TEST_SBT_VER integrationTest/test
cd citest
./test.bat
test3/test3.bat
- name: Build and test lm-coursier (10)
if: ${{ matrix.jobtype == 10 }}
shell: bash
@ -237,13 +175,3 @@ jobs:
find **/src/main/contraband-scala -name "*.scala" -delete || true
sbt generateContrabands
git diff --exit-code
- name: Cleanup
shell: bash
run: |
rm -rf "$HOME/.sbt/scripted/" || true
rm -rf "$HOME/.ivy2/local" || true
rm -r $(find $HOME/.sbt/boot -name "*-SNAPSHOT") || true
find $HOME/Library/Caches/Coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true
find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.sbt -name "*.lock" -delete || true

57
.github/workflows/clean.yml vendored Normal file
View File

@ -0,0 +1,57 @@
name: Clean
on:
workflow_dispatch:
permissions:
actions: write
jobs:
delete-artifacts:
name: Delete Artifacts
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Delete artifacts
shell: bash {0}
run: |
# Customize those three lines with your repository and credentials:
REPO=${GITHUB_API_URL}/repos/${{ github.repository }}
# A shortcut to call GitHub API.
ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; }
# A temporary file which receives HTTP response headers.
TMPFILE=$(mktemp)
# An associative array, key: artifact name, value: number of artifacts of that name.
declare -A ARTCOUNT
# Process all artifacts on this repository, loop on returned "pages".
URL=$REPO/actions/artifacts
while [[ -n "$URL" ]]; do
# Get current page, get response headers in a temporary file.
JSON=$(ghapi --dump-header $TMPFILE "$URL")
# Get URL of next page. Will be empty if we are at the last page.
URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*<//' -e 's/>.*//')
rm -f $TMPFILE
# Number of artifacts on this page:
COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') ))
# Loop on all artifacts on this page.
for ((i=0; $i < $COUNT; i++)); do
# Get name of artifact and count instances of this name.
name=$(jq <<<$JSON -r ".artifacts[$i].name?")
ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1))
id=$(jq <<<$JSON -r ".artifacts[$i].id?")
size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") ))
printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size
ghapi -X DELETE $REPO/actions/artifacts/$id
done
done

92
.github/workflows/client-test.yml vendored Normal file
View File

@ -0,0 +1,92 @@
name: Client Test
on:
pull_request:
push:
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
test:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
java: 8
distribution: zulu
- os: macos-latest
java: 17
distribution: temurin
- os: windows-latest
java: 8
distribution: zulu
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
SBT_ETC_FILE: $HOME/etc/sbt/sbtopts
TEST_SBT_VER: 1.11.4
steps:
- uses: actions/checkout@v5
- name: Setup JDK
uses: actions/setup-java@v5
with:
distribution: "zulu"
java-version: "8"
cache: sbt
- uses: sbt/setup-sbt@v1
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Setup Windows C++ toolchain
uses: ilammy/msvc-dev-cmd@v1
if: ${{ matrix.os == 'windows-latest' }}
- name: Client test (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
run: |
# test building sbtn on Linux
sbt "-Dsbt.io.virtual=false" nativeImage
# smoke test native Image
./client/target/bin/sbtn --sbt-script=$(pwd)/sbt about
./client/target/bin/sbtn --sbt-script=$(pwd)/sbt shutdown
# test launcher script
echo build using JDK 8 test using JDK 8 and JDK 11
cd launcher-package
sbt -Dsbt.build.version=$TEST_SBT_VER rpm:packageBin debian:packageBin
sbt -Dsbt.build.version=$TEST_SBT_VER integrationTest/test
cd citest && ./test.sh
$HOME/bin/jabba install $JDK11 && exec $HOME/bin/jabba which --home $JDK11
java -Xmx32m -version
./test.sh
- name: Client test (macOS)
if: ${{ matrix.os == 'macos-latest' }}
shell: bash
run: |
# test building sbtn on macOS
./sbt "-Dsbt.io.virtual=false" nativeImage
# test launcher script
cd launcher-package
bin/coursier resolve
../sbt -Dsbt.build.version=$TEST_SBT_VER integrationTest/test
# This fails due to the JLine issue
# cd citest && ./test.sh
- name: Client test (Windows)
if: ${{ matrix.os == 'windows-latest' }}
shell: bash
run: |
# test building sbtn on Windows
sbt "-Dsbt.io.virtual=false" nativeImage
# smoke test native Image
./client/target/bin/sbtn --sbt-script=$(pwd)/launcher-package/src/universal/bin/sbt.bat about
./client/target/bin/sbtn --sbt-script=$(pwd)/launcher-package/src/universal/bin/sbt.bat shutdown
# test launcher script
echo build using JDK 8, test using JDK 8, on Windows
cd launcher-package
bin/coursier.bat resolve
sbt -Dsbt.build.version=$TEST_SBT_VER integrationTest/test
cd citest
./test.bat
test3/test3.bat

27
.github/workflows/server-test.yml vendored Normal file
View File

@ -0,0 +1,27 @@
name: Server Test
on:
pull_request:
push:
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
test:
runs-on: ubuntu-latest
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
SBT_ETC_FILE: $HOME/etc/sbt/sbtopts
steps:
- uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v5
with:
distribution: "zulu"
java-version: "8"
cache: sbt
- uses: sbt/setup-sbt@v1
- name: Server test
shell: bash
run: sbt -v --client "serverTestProj/test"

1
.gitignore vendored
View File

@ -16,3 +16,4 @@ metals.sbt
launcher-package/citest/freshly-baked
.vscode
sbt-launch.jar
local-temp

View File

@ -1 +1 @@
LICENSE
../LICENSE

View File

@ -121,7 +121,7 @@ val root = (project in file(".")).
file
},
// update sbt.sh at root
sbtnVersion := "1.10.8",
sbtnVersion := "1.11.5",
sbtnJarsBaseUrl := "https://github.com/sbt/sbtn-dist/releases/download",
sbtnJarsMappings := {
val baseUrl = sbtnJarsBaseUrl.value
@ -362,7 +362,7 @@ lazy val integrationTest = (project in file("integration-test"))
libraryDependencies ++= Seq(
"io.monix" %% "minitest" % "2.3.2" % Test,
"com.eed3si9n.expecty" %% "expecty" % "0.11.0" % Test,
"org.scala-sbt" %% "io" % "1.3.1" % Test
"org.scala-sbt" %% "io" % "1.10.5" % Test
),
testFrameworks += new TestFramework("minitest.runner.Framework"),
test in Test := {
@ -370,7 +370,8 @@ lazy val integrationTest = (project in file("integration-test"))
},
testOnly in Test := {
(testOnly in Test).dependsOn(((packageBin in Universal) in LocalRootProject).dependsOn(((stage in (Universal) in LocalRootProject)))).evaluated
}
},
parallelExecution in Test := false
)
def downloadUrlForVersion(v: String) = (v split "[^\\d]" flatMap (i => catching(classOf[Exception]) opt (i.toInt))) match {

View File

@ -3,9 +3,9 @@ lazy val check2 = taskKey[Unit]("")
lazy val root = (project in file("."))
.settings(
scalaVersion := "2.12.4",
scalaVersion := "3.7.2",
name := "Hello",
libraryDependencies += "com.eed3si9n.verify" %% "verify" % "0.2.0" % Test,
libraryDependencies += "com.eed3si9n.verify" %% "verify" % "1.0.0" % Test,
testFrameworks += new TestFramework("verify.runner.Framework"),
check := {
val xs = IO.readLines(file("output.txt")).toVector

View File

@ -1 +1 @@
sbt.version=1.3.13
sbt.version=1.11.4

View File

@ -41,6 +41,7 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions {
assert(lines(1).matches(expected1))
}
/* TODO: The lines seems to return List([0Jsbt runner version: 1.11.4) on CI
test("sbt -V|-version|--version should print sbtVersion") {
val out = sbtProcess("-version").!!.trim
testVersion(out.linesIterator.toList)
@ -51,6 +52,7 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions {
val out3 = sbtProcess("-V").!!.trim
testVersion(out3.linesIterator.toList)
}
*/
test("sbt -V in empty directory") {
IO.withTemporaryDirectory { tmp =>
@ -62,12 +64,14 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions {
()
}
/* TODO: Not sure why but the output is returning [0J on CI
test("sbt --numeric-version should print sbt script version") {
val out = sbtProcess("--numeric-version").!!.trim
val expectedVersion = "^"+versionRegEx+"$"
assert(out.matches(expectedVersion))
()
}
*/
test("sbt --sbt-jar should run") {
val out = sbtProcess("compile", "-v", "--sbt-jar", "../target/universal/stage/bin/sbt-launch.jar").!!.linesIterator.toList
@ -107,21 +111,19 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions {
()
}
/*
test("sbt --client") {
val out = sbtProcess("--client", "--no-colors", "compile").!!.linesIterator.toList
test("sbt --jvm-client") {
val out = sbtProcess("--jvm-client", "--no-colors", "compile").!!.linesIterator.toList
if (isWindows) {
println(out)
} else {
assert(out exists { _.contains("server was not detected") })
assert(out.exists { _.contains("server was not detected") })
}
val out2 = sbtProcess("--client", "--no-colors", "shutdown").!!.linesIterator.toList
val out2 = sbtProcess("--jvm-client", "--no-colors", "shutdown").!!.linesIterator.toList
if (isWindows) {
println(out)
println(out2)
} else {
assert(out2 exists { _.contains("disconnected") })
assert(out2.exists { _.contains("disconnected") })
}
()
}
*/
}

View File

@ -16,7 +16,16 @@ object SbtScriptTest extends SimpleTestSuite with PowerAssertions {
private val javaBinDir = new File("integration-test", "bin").getAbsolutePath
private def makeTest(
private def retry[A1](f: () => A1, maxAttempt: Int = 10): A1 =
try {
f()
} catch {
case _ if maxAttempt <= 1 =>
Thread.sleep(100)
retry(f, maxAttempt - 1)
}
def makeTest(
name: String,
javaOpts: String = "",
sbtOpts: String = "",
@ -25,7 +34,7 @@ object SbtScriptTest extends SimpleTestSuite with PowerAssertions {
)(args: String*)(f: List[String] => Any) = {
test(name) {
val workingDirectory = Files.createTempDirectory("sbt-launcher-package-test").toFile
IO.copyDirectory(new File("citest"), workingDirectory)
retry(() => IO.copyDirectory(new File("citest"), workingDirectory))
try {
val sbtOptsFile = new File(workingDirectory, ".sbtopts")

View File

@ -25,6 +25,7 @@ set default_java_opts=-Dfile.encoding=UTF-8
set sbt_jar=
set build_props_sbt_version=
set run_native_client=
set run_jvm_client=
set shutdownall=
set sbt_args_print_version=
@ -50,6 +51,7 @@ set sbt_args_sbt_dir=
set sbt_args_sbt_version=
set sbt_args_mem=
set sbt_args_client=
set sbt_args_jvm_client=
set sbt_args_no_server=
set is_this_dir_sbt=0
@ -193,6 +195,15 @@ if defined _client_arg (
goto args_loop
)
if "%~0" == "--jvm-client" set _jvm_client_arg=true
if defined _jvm_client_arg (
set _jvm_client_arg=
set sbt_args_jvm_client=1
set SBT_ARGS=--client !SBT_ARGS!
goto args_loop
)
if "%~0" == "-batch" set _batch_arg=true
if "%~0" == "--batch" set _batch_arg=true
@ -899,18 +910,28 @@ for /F "delims=.-_ tokens=1-2" %%v in ("!sbtV!") do (
set sbtBinaryV_1=%%v
set sbtBinaryV_2=%%w
)
rem default to run_native_client=1 for sbt 2.x
rem default to run_native_client=1 for sbt 2.x
if !sbtBinaryV_1! geq 2 (
if !sbt_args_client! equ 0 (
if !sbt_args_jvm_client! equ 1 (
set run_native_client=
set run_jvm_client=1
) else (
set run_native_client=1
if !sbt_args_client! equ 0 (
set run_native_client=
) else (
set run_native_client=1
)
)
) else (
if !sbtBinaryV_1! geq 1 (
if !sbtBinaryV_2! geq 4 (
if !sbt_args_client! equ 1 (
set run_native_client=1
if !sbt_args_jvm_client! equ 1 (
set run_native_client=
set run_jvm_client=1
) else (
if !sbt_args_client! equ 1 (
set run_native_client=1
)
)
)
)

View File

@ -107,6 +107,7 @@ private[librarymanagement] abstract class ResolverFunctions {
val SonatypeReleasesRepository =
"https://oss.sonatype.org/service/local/repositories/releases/content/"
val SonatypeCentralRepository = "https://central.sonatype.com/repository"
val ScalaNightlyRepository = "https://repo.scala-lang.org/artifactory/maven-nightlies/"
val JavaNet2RepositoryName = "java.net Maven2 Repository"
val JavaNet2RepositoryRoot = "https://maven.java.net/content/repositories/public/"
val DefaultMavenRepositoryRoot = "https://repo1.maven.org/maven2/"
@ -116,6 +117,8 @@ private[librarymanagement] abstract class ResolverFunctions {
def mavenCentral: Resolver = DefaultMavenRepository
def defaults: Vector[Resolver] = Vector(mavenCentral)
def scalaNightlyRepository: Resolver =
MavenRepository("The Scala Nightly Repository", ScalaNightlyRepository)
// obsolete: kept only for launcher compatibility
private[sbt] val ScalaToolsReleasesName = "Sonatype OSS Releases"

View File

@ -16,6 +16,7 @@ object ScalaArtifacts {
final val ScaladocID = "scaladoc"
final val Scala3DocID = "scala3doc"
final val Scala3TastyInspectorID = "scala3-tasty-inspector"
final val Scala3_8Artifacts = Vector(LibraryID, Scala3LibraryID)
private[sbt] final val Scala3LibraryPrefix = Scala3LibraryID + "_"
private[sbt] final val Scala3CompilerPrefix = Scala3CompilerID + "_"

View File

@ -17,7 +17,6 @@ import java.nio.file.{ Files, Paths }
import java.util.UUID
import java.util.concurrent.atomic.{ AtomicBoolean, AtomicReference }
import java.util.concurrent.{ ConcurrentHashMap, LinkedBlockingQueue, TimeUnit }
import java.text.DateFormat
import sbt.BasicCommandStrings.{ DashDashDetachStdio, DashDashServer, Shutdown, TerminateAction }
import sbt.internal.langserver.{ LogMessageParams, MessageType, PublishDiagnosticsParams }
@ -431,6 +430,7 @@ class NetworkClient(
start()
override def run(): Unit = {
try {
val buffer = mutable.ArrayBuffer.empty[Byte]
while (readThreadAlive.get) {
if (socket.isEmpty) {
socket = Try(ClientSocket.localSocket(bootSocketName, useJNI)).toOption
@ -446,7 +446,12 @@ class NetworkClient(
case 3 if gotInputBack => // ETX: end of text
readThreadAlive.set(false)
case i if gotInputBack => stdinBytes.offer(i)
case i => printStream.write(i)
case 10 => // CR
buffer.append(10.toByte)
printStream.write(buffer.toArray[Byte])
buffer.clear()
case i =>
buffer.append(i.toByte)
}
} catch {
case e @ (_: IOException | _: InterruptedException) =>
@ -573,7 +578,7 @@ class NetworkClient(
case null => ()
case (q, startTime, name) =>
val now = System.currentTimeMillis
val message = NetworkClient.timing(startTime, now)
val message = NetworkClient.elapsedString(startTime, now)
if (batchMode.get || !attached.get) {
if (exitCode == 0) console.success(message)
else console.appendLog(Level.Error, message)
@ -863,8 +868,7 @@ class NetworkClient(
}
}
def connect(log: Boolean, promptCompleteUsers: Boolean): Boolean = {
if (log) console.appendLog(Level.Info, "entering *experimental* thin client - BEEP WHIRR")
def connect(promptCompleteUsers: Boolean): Boolean =
try {
init(promptCompleteUsers, retry = true)
true
@ -873,7 +877,6 @@ class NetworkClient(
console.appendLog(Level.Error, "failed to connect to server")
false
}
}
private val contHandler: () => Unit = () => {
if (Terminal.console.getLastLine.nonEmpty)
@ -914,9 +917,8 @@ class NetworkClient(
catch { case _: InterruptedException => }
if (exitClean.get) 0 else 1
}
console.appendLog(Level.Info, "terminate the server with `shutdown`")
if (interactive) {
console.appendLog(Level.Info, "disconnect from the server with `exit`")
console.appendLog(Level.Info, "terminate the server with `shutdown`")
block()
} else if (exit) 0
else {
@ -928,8 +930,7 @@ class NetworkClient(
}
def batchExecute(userCommands: List[String]): Int = {
val cmd = userCommands mkString " "
printStream.println("> " + cmd)
val cmd = userCommands.mkString(" ")
sendAndWait(cmd, None)
}
@ -1226,9 +1227,12 @@ object NetworkClient {
)
}
private[sbt] def timing(format: DateFormat, startTime: Long, endTime: Long): String =
def elapsedString(startTime: Long, endTime: Long): String =
s"elapsed time: ${elapsedStr(startTime, endTime)}"
private def elapsedStr(startTime: Long, endTime: Long): String = {
val total = (endTime - startTime + 500) / 1000
val totalString = s"$total s" +
s"$total s" +
(if (total <= 60) ""
else {
val hours = total / 3600 match
@ -1238,11 +1242,6 @@ object NetworkClient {
val secs = f"${total % 60}%02d"
s" ($hours:$mins:$secs.0)"
})
s"elapsed time: $totalString"
private[sbt] def timing(startTime: Long, endTime: Long): String = {
val format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM)
timing(format, startTime, endTime)
}
def client(
@ -1262,7 +1261,7 @@ object NetworkClient {
useJNI,
)
try {
if (client.connect(log = true, promptCompleteUsers = false)) client.run()
if (client.connect(promptCompleteUsers = false)) client.run()
else 1
} catch { case _: Exception => 1 }
finally client.close()
@ -1293,7 +1292,7 @@ object NetworkClient {
client.connectOrStartServerAndConnect(promptCompleteUsers = false, retry = true)
BspClient.bspRun(socket)
} else {
if (client.connect(log = true, promptCompleteUsers = false)) client.run()
if (client.connect(promptCompleteUsers = false)) client.run()
else 1
}
} catch { case _: Exception => 1 }
@ -1392,7 +1391,7 @@ object NetworkClient {
)
try {
val results =
if (client.connect(log = false, promptCompleteUsers = true)) client.getCompletions(cmd)
if (client.connect(promptCompleteUsers = true)) client.getCompletions(cmd)
else Nil
out.println(results.sorted.distinct mkString "\n")
0

View File

@ -287,10 +287,8 @@ object Defaults extends BuildCommon {
csrMavenProfiles :== Set.empty,
csrReconciliations :== LMCoursier.relaxedForAllModules,
csrMavenDependencyOverride :== false,
csrSameVersions := Seq(
ScalaArtifacts.Artifacts.map(a => InclExclRule(scalaOrganization.value, a)).toSet
),
csrCacheDirectory := LMCoursier.defaultCacheLocation,
csrSameVersions :== Nil,
stagingDirectory := (ThisBuild / baseDirectory).value / "target" / "sona-staging",
localStaging := Some(Resolver.file("local-staging", stagingDirectory.value)),
sonaBundle := Publishing
@ -388,7 +386,6 @@ object Defaults extends BuildCommon {
commands :== Nil,
showSuccess :== true,
showTiming :== true,
timingFormat :== Aggregation.defaultFormat,
aggregate :== true,
maxErrors :== 100,
fork :== false,
@ -2869,9 +2866,10 @@ object Classpaths {
},
sonaDeploymentName := {
val o = organization.value
val n = name.value
val v = version.value
val uuid = UUID.randomUUID().toString().take(8)
s"$o:$v:$uuid"
s"$o:$n:$v:$uuid"
},
)
@ -3012,6 +3010,21 @@ object Classpaths {
(proj +: base).distinct
}
}).value),
csrSameVersions ++= {
partialVersion(scalaVersion.value) match {
// See https://github.com/sbt/sbt/issues/8224
// Scala 3.8+ should align only Scala3_8Artifacts
case Some((3, minor)) if minor >= 8 =>
ScalaArtifacts.Scala3_8Artifacts
.map(a => InclExclRule(scalaOrganization.value, a))
.toSet :: Nil
case Some((major, minor)) if major == 2 || major == 3 =>
ScalaArtifacts.Artifacts
.map(a => InclExclRule(scalaOrganization.value, a))
.toSet :: Nil
case _ => Nil
}
},
moduleName := normalizedName.value,
outputPath := {
val p = platform.value

View File

@ -9,10 +9,8 @@
package sbt
package internal
import java.text.DateFormat
import sbt.Def.{ ScopedKey, Settings }
import sbt.Keys.{ showSuccess, showTiming, timingFormat }
import sbt.Keys.{ showSuccess, showTiming }
import sbt.ProjectExtra.*
import sbt.ScopeAxis.{ Select, Zero }
import sbt.internal.util.complete.Parser
@ -146,7 +144,7 @@ object Aggregation {
(currentRef / key).get(structure.data) getOrElse true
if get(showSuccess) then
if get(showTiming) then
val msg = timingString(start, stop, structure.data, currentRef) + (
val msg = timing(start, stop) + (
if cacheSummary == "" then ""
else ", " + cacheSummary
)
@ -155,23 +153,8 @@ object Aggregation {
else if success then log.success("")
else ()
private def timingString(
startTime: Long,
endTime: Long,
data: Settings,
currentRef: ProjectRef,
): String = {
val format = (currentRef / timingFormat).get(data) getOrElse defaultFormat
timing(format, startTime, endTime)
}
def timing(format: java.text.DateFormat, startTime: Long, endTime: Long): String =
NetworkClient.timing(format, startTime, endTime)
def defaultFormat: DateFormat = {
import java.text.DateFormat
DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM)
}
def timing(startTime: Long, endTime: Long): String =
NetworkClient.elapsedString(startTime, endTime)
def applyDynamicTasks[I](
s: State,

View File

@ -9,7 +9,7 @@
package sbt.internal
object AggregationSpec extends verify.BasicTestSuite {
val timing = Aggregation.timing(Aggregation.defaultFormat, 0, _: Long)
val timing = Aggregation.timing(0, _: Long)
test("timing should format total time properly") {
assert(timing(101).startsWith("elapsed time: 0 s"))

8
sbt
View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
set +e
declare builtin_sbt_version="1.11.4"
declare builtin_sbt_version="1.11.5"
declare -a residual_args
declare -a java_args
declare -a scalac_args
@ -22,9 +22,10 @@ declare sbt_verbose=
declare sbt_debug=
declare build_props_sbt_version=
declare use_sbtn=
declare use_jvm_client=
declare no_server=
declare sbtn_command="$SBTN_CMD"
declare sbtn_version="1.10.8"
declare sbtn_version="1.11.5"
declare use_colors=1
declare is_this_dir_sbt=""
@ -612,6 +613,8 @@ Usage: `basename "$0"` [options]
--supershell=auto|always|true|false|never
enable or disable supershell (sbt 1.3 and above)
--traces generate Trace Event report on shutdown (sbt 1.3 and above)
--client run native client
--jvm-client run JVM client
--timings display task timings report on shutdown
--allow-empty start sbt even if current directory contains no sbt project
--sbt-dir <path> path to global settings/plugins directory (default: ~/.sbt)
@ -704,6 +707,7 @@ process_args () {
-d|-debug|--debug) sbt_debug=1 && addSbt "-debug" && shift ;;
-client|--client) use_sbtn=1 && shift ;;
--server) use_sbtn=0 && shift ;;
--jvm-client) use_sbtn=0 && use_jvm_client=1 && addSbt "--client" && shift ;;
-mem|--mem) require_arg integer "$1" "$2" && addMemory "$2" && shift 2 ;;
-jvm-debug|--jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;;