Merge branch '1.10.x' into wip/merge-1.10.x

This commit is contained in:
Eugene Yokota 2025-05-12 03:18:45 -04:00
commit 1795b797bf
6 changed files with 95 additions and 51 deletions

View File

@ -33,19 +33,32 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions {
()
}
def testVersion(lines: List[String]): Unit = {
assert(lines.size >= 2)
val expected0 = s"(?m)^sbt version in this project: $versionRegEx(\\r)?"
assert(lines(0).matches(expected0))
val expected1 = s"sbt runner version: $versionRegEx$$"
assert(lines(1).matches(expected1))
}
test("sbt -V|-version|--version should print sbtVersion") {
val out = sbtProcess("-version").!!.trim
val expectedVersion =
s"""|(?m)^sbt version in this project: $versionRegEx(\\r)?
|sbt script version: $versionRegEx$$
|""".stripMargin.trim.replace("\n", "\\n")
assert(out.matches(expectedVersion))
testVersion(out.linesIterator.toList)
val out2 = sbtProcess("--version").!!.trim
assert(out2.matches(expectedVersion))
testVersion(out2.linesIterator.toList)
val out3 = sbtProcess("-V").!!.trim
assert(out3.matches(expectedVersion))
testVersion(out3.linesIterator.toList)
}
test("sbt -V in empty directory") {
IO.withTemporaryDirectory { tmp =>
val out = sbtProcessInDir(tmp)("-V").!!.trim
val expectedVersion = "^"+versionRegEx+"$"
val targetDir = new File(tmp, "target")
assert(!targetDir.exists, "expected target directory to not exist, but existed")
}
()
}

View File

@ -51,6 +51,7 @@ set sbt_args_sbt_version=
set sbt_args_mem=
set sbt_args_client=
set sbt_args_no_server=
set is_this_dir_sbt=0
rem users can set SBT_OPTS via .sbtopts
if exist .sbtopts for /F %%A in (.sbtopts) do (
@ -532,14 +533,21 @@ set SBT_ARGS=!SBT_ARGS! %0
goto args_loop
:args_end
if exist build.sbt (
set is_this_dir_sbt=1
)
if exist project\build.properties (
set is_this_dir_sbt=1
)
rem Confirm a user's intent if the current directory does not look like an sbt
rem top-level directory and the "new" command was not given.
if not defined sbt_args_allow_empty if not defined sbt_args_print_version if not defined sbt_args_print_sbt_version if not defined sbt_args_print_sbt_script_version if not defined shutdownall if not exist build.sbt (
if not exist project\ (
if not defined sbt_args_allow_empty if not defined sbt_args_print_version if not defined sbt_args_print_sbt_version if not defined sbt_args_print_sbt_script_version if not defined shutdownall (
if not !is_this_dir_sbt! equ 1 (
if not defined sbt_new (
echo [error] Neither build.sbt nor a 'project' directory in the current directory: "%CD%"
echo [error] run 'sbt new', touch build.sbt, or run 'sbt --allow-empty'.
>&2 echo [error] Neither build.sbt nor a 'project' directory in the current directory: "%CD%"
>&2 echo [error] run 'sbt new', touch build.sbt, or run 'sbt --allow-empty'.
goto error
)
)
@ -555,7 +563,7 @@ if !shutdownall! equ 1 (
taskkill /F /PID %%i
set /a count=!count!+1
)
echo shutdown !count! sbt processes
>&2 echo shutdown !count! sbt processes
goto :eof
)
@ -667,9 +675,14 @@ if !sbt_args_print_sbt_version! equ 1 (
)
if !sbt_args_print_version! equ 1 (
call :set_sbt_version
echo sbt version in this project: !sbt_version!
echo sbt script version: !init_sbt_version!
if !is_this_dir_sbt! equ 1 (
call :set_sbt_version
echo sbt version in this project: !sbt_version!
)
echo sbt runner version: !init_sbt_version!
>&2 echo.
>&2 echo [info] sbt runner ^(sbt-the-batch-script^) is a runner to run any declared version of sbt.
>&2 echo [info] Actual version of the sbt is declared using project\build.properties for each build.
goto :eof
)
@ -910,14 +923,14 @@ set /a required_version=8
if /I !JAVA_VERSION! GEQ !required_version! (
exit /B 0
)
echo.
echo The Java Development Kit ^(JDK^) installation you have is not up to date.
echo sbt requires at least version !required_version!+, you have
echo version "!JAVA_VERSION!"
echo.
echo Please go to http://www.oracle.com/technetwork/java/javase/downloads/ and download
echo a valid JDK and install before running sbt.
echo.
>&2 echo.
>&2 echo The Java Development Kit ^(JDK^) installation you have is not up to date.
>&2 echo sbt requires at least version !required_version!+, you have
>&2 echo version "!JAVA_VERSION!"
>&2 echo.
>&2 echo Go to https://adoptium.net/ etc and download
>&2 echo a valid JDK and install before running sbt.
>&2 echo.
exit /B 1
:copyrt

View File

@ -2127,7 +2127,7 @@ object Defaults extends BuildCommon {
val store = analysisStore(compileAnalysisFile)
val c = fileConverter.value
// TODO - Should readAnalysis + saveAnalysis be scoped by the compile task too?
val analysisResult = Retry(compileIncrementalTaskImpl(bspTask, s, ci, ping))
val analysisResult = Retry.io(compileIncrementalTaskImpl(bspTask, s, ci, ping))
val analysisOut = c.toVirtualFile(setup.cachePath())
val contents = AnalysisContents.create(analysisResult.analysis(), analysisResult.setup())
store.set(contents)

View File

@ -105,7 +105,8 @@ object Compiler:
for lib <- scalaDeps.take(1) do
val libVer = lib.module.revision
val libName = lib.module.name
val n = Keys.name.value
val proj =
Def.displayBuildRelative(Keys.thisProjectRef.value.build, Keys.thisProjectRef.value)
if VersionNumber(sv).matchesSemVer(SemanticSelector(s"<$libVer")) then
val err = !Keys.allowUnsafeScalaLibUpgrade.value
val fix =
@ -117,13 +118,13 @@ object Compiler:
|contain the newer $libName $libVer, even if the scalaVersion is $sv.
|Compilation (macro expansion) or using the Scala REPL in sbt may fail with a LinkageError.""".stripMargin
val msg =
s"""Expected `$n/scalaVersion` to be $libVer or later, but found $sv.
s"""Expected `$proj scalaVersion` to be $libVer or later, but found $sv.
|To support backwards-only binary compatibility (SIP-51), the Scala 2.13 compiler
|should not be older than $libName on the dependency classpath.
|
|$fix
|
|See `$n/evicted` to know why $libName $libVer is getting pulled in.
|See `$proj evicted` to know why $libName $libVer is getting pulled in.
|""".stripMargin
if err then sys.error(msg)
else s.log.warn(msg)

View File

@ -11,7 +11,7 @@ object Dependencies {
sys.env.get("BUILD_VERSION") orElse sys.props.get("sbt.build.version")
// sbt modules
private val ioVersion = nightlyVersion.getOrElse("1.10.4")
private val ioVersion = nightlyVersion.getOrElse("1.10.5")
val zincVersion = nightlyVersion.getOrElse("2.0.0-M4")
private val sbtIO = "org.scala-sbt" %% "io" % ioVersion

63
sbt
View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
set +e
declare builtin_sbt_version="1.10.10"
declare builtin_sbt_version="1.10.11"
declare -a residual_args
declare -a java_args
declare -a scalac_args
@ -26,6 +26,7 @@ declare no_server=
declare sbtn_command="$SBTN_CMD"
declare sbtn_version="1.10.8"
declare use_colors=1
declare is_this_dir_sbt=""
### ------------------------------- ###
### Helper methods for BASH scripts ###
@ -163,7 +164,7 @@ acquire_sbt_jar () {
sbt_jar="$download_jar"
else
sbt_url=$(jar_url "$launcher_sv")
echoerr "downloading sbt launcher $launcher_sv"
dlog "downloading sbt launcher $launcher_sv"
download_url "$sbt_url" "${download_jar}.temp"
download_url "${sbt_url}.sha1" "${download_jar}.sha1"
if command -v shasum > /dev/null; then
@ -199,7 +200,7 @@ acquire_sbtn () {
archive_target="$p/sbtn-${arch}-pc-linux-${sbtn_v}.tar.gz"
url="https://github.com/sbt/sbtn-dist/releases/download/v${sbtn_v}/sbtn-${arch}-pc-linux-${sbtn_v}.tar.gz"
else
echoerr "sbtn is not supported on $arch"
echoerr_error "sbtn is not supported on $arch"
exit 2
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
@ -211,14 +212,14 @@ acquire_sbtn () {
archive_target="$p/sbtn-x86_64-pc-win32-${sbtn_v}.zip"
url="https://github.com/sbt/sbtn-dist/releases/download/v${sbtn_v}/sbtn-x86_64-pc-win32-${sbtn_v}.zip"
else
echoerr "sbtn is not supported on $OSTYPE"
echoerr_error "sbtn is not supported on $OSTYPE"
exit 2
fi
if [[ -f "$target" ]]; then
sbtn_command="$target"
else
echoerr "downloading sbtn ${sbtn_v} for ${arch}"
dlog "downloading sbtn ${sbtn_v} for ${arch}"
download_url "$url" "$archive_target"
if [[ "$OSTYPE" == "linux-gnu"* ]] || [[ "$OSTYPE" == "darwin"* ]]; then
tar zxf "$archive_target" --directory "$p"
@ -353,7 +354,7 @@ require_arg () {
local opt="$2"
local arg="$3"
if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then
echo "$opt requires <$type> argument"
echoerr "$opt requires <$type> argument"
exit 1
fi
}
@ -457,19 +458,19 @@ checkJava() {
# Now check to see if it's a good enough version
local good_enough="$(expr $java_version ">=" $required_version)"
if [[ "$java_version" == "" ]]; then
echo
echo "No Java Development Kit (JDK) installation was detected."
echo Please go to http://www.oracle.com/technetwork/java/javase/downloads/ and download.
echo
echoerr
echoerr "No Java Development Kit (JDK) installation was detected."
echoerr Go to https://adoptium.net/ etc and download.
echoerr
exit 1
elif [[ "$good_enough" != "1" ]]; then
echo
echo "The Java Development Kit (JDK) installation you have is not up to date."
echo $script_name requires at least version $required_version+, you have
echo version $java_version
echo
echo Please go to http://www.oracle.com/technetwork/java/javase/downloads/ and download
echo a valid JDK and install before running $script_name.
echoerr
echoerr "The Java Development Kit (JDK) installation you have is not up to date."
echoerr $script_name requires at least version $required_version+, you have
echoerr version $java_version
echoerr
echoerr Go to https://adoptium.net/ etc and download
echoerr a valid JDK and install before running $script_name.
echo
exit 1
fi
@ -484,7 +485,6 @@ copyRt() {
java9_rt=$(echo "$java9_ext/rt.jar")
vlog "[copyRt] java9_rt = '$java9_rt'"
if [[ ! -f "$java9_rt" ]]; then
echo copying runtime jar...
mkdir -p "$java9_ext"
"$java_cmd" \
"${sbt_options[@]}" \
@ -497,11 +497,17 @@ copyRt() {
fi
}
detect_working_directory() {
if [[ -f ./build.sbt || -f ./project/build.properties ]]; then
is_this_dir_sbt=1
fi
}
# Confirm a user's intent if the current directory does not look like an sbt
# top-level directory and neither the --allow-empty option nor the "new" command was given.
checkWorkingDirectory() {
if [[ ! -n "$allow_empty" ]]; then
[[ -f ./build.sbt || -d ./project || -n "$sbt_new" ]] || {
[[ -n "$is_this_dir_sbt" || -n "$sbt_new" ]] || {
echoerr_error "Neither build.sbt nor a 'project' directory in the current directory: $(pwd)"
echoerr_error "run 'sbt new', touch build.sbt, or run 'sbt --allow-empty'."
echoerr_error ""
@ -534,19 +540,25 @@ run() {
addJava "-Dsbt.cygwin=true"
fi
detect_working_directory
if [[ $print_sbt_version ]]; then
execRunner "$java_cmd" -jar "$sbt_jar" "sbtVersion" | tail -1 | sed -e 's/\[info\]//g'
elif [[ $print_sbt_script_version ]]; then
echo "$init_sbt_version"
elif [[ $print_version ]]; then
execRunner "$java_cmd" -jar "$sbt_jar" "sbtVersion" | tail -1 | sed -e 's/\[info\]/sbt version in this project:/g'
echo "sbt script version: $init_sbt_version"
if [[ -n "$is_this_dir_sbt" ]]; then
execRunner "$java_cmd" -jar "$sbt_jar" "sbtVersion" | tail -1 | sed -e 's/\[info\]/sbt version in this project:/g'
fi
echo "sbt runner version: $init_sbt_version"
echoerr ""
echoerr "[info] sbt runner (sbt-the-shell-script) is a runner to run any declared version of sbt."
echoerr "[info] Actual version of the sbt is declared using project/build.properties for each build."
elif [[ $shutdownall ]]; then
local sbt_processes=( $(jps -v | grep sbt-launch | cut -f1 -d ' ') )
for procId in "${sbt_processes[@]}"; do
kill -9 $procId
done
echo "shutdown ${#sbt_processes[@]} sbt processes"
echoerr "shutdown ${#sbt_processes[@]} sbt processes"
else
checkWorkingDirectory
# run sbt
@ -795,7 +807,12 @@ runNativeClient() {
unset 'original_args[i]'
fi
done
sbt_script=$0
if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
sbt_script="$0.bat"
else
sbt_script="$0"
fi
sbt_script=${sbt_script/ /%20}
execRunner "$sbtn_command" "--sbt-script=$sbt_script" "${original_args[@]}"
}