From deb8f6d7678b88b4c8c4530ee5f162207cf5f3a7 Mon Sep 17 00:00:00 2001 From: eugene yokota Date: Sun, 17 May 2026 03:01:12 -0400 Subject: [PATCH] [2.x] Add runner support for execution log (#9237) **Problem/Solution** This adds runner commandline option experimental_execution_log. --- .../src/test/scala/RunnerScriptTest.scala | 4 ++++ launcher-package/src/universal/bin/sbt.bat | 22 +++++++++++++++++++ sbt | 3 +++ sbtw/src/main/scala/sbtw/ArgParser.scala | 3 +++ .../src/main/scala/sbtw/LauncherOptions.scala | 1 + sbtw/src/main/scala/sbtw/Runner.scala | 1 + 6 files changed, 34 insertions(+) diff --git a/launcher-package/integration-test/src/test/scala/RunnerScriptTest.scala b/launcher-package/integration-test/src/test/scala/RunnerScriptTest.scala index dfc728f84..3abe411df 100644 --- a/launcher-package/integration-test/src/test/scala/RunnerScriptTest.scala +++ b/launcher-package/integration-test/src/test/scala/RunnerScriptTest.scala @@ -330,4 +330,8 @@ object RunnerScriptTest extends verify.BasicTestSuite with ShellScriptUtil: s"Should not have errors from comment character, but found: ${errorMessages.mkString(", ")}" ) + testOutput("sbt --experimental_execution_log=true")("--experimental_execution_log=true", "-v"): + (out: List[String]) => + assert(out.contains[String]("-Dsbt.experimental_execution_log=true")) + end RunnerScriptTest diff --git a/launcher-package/src/universal/bin/sbt.bat b/launcher-package/src/universal/bin/sbt.bat index 323b263a8..8cb79e2ef 100755 --- a/launcher-package/src/universal/bin/sbt.bat +++ b/launcher-package/src/universal/bin/sbt.bat @@ -54,6 +54,7 @@ set sbt_args_mem= set sbt_args_client= set sbt_args_jvm_client= set sbt_args_no_server= +set sbt_args_experimental_execution_log= set is_this_dir_sbt=0 rem users can set SBT_OPTS via .sbtopts @@ -419,6 +420,21 @@ if defined _color_arg ( goto args_loop ) +if "%~0" == "--experimental_execution_log" set _experimental_execution_log_arg=true + +if defined _experimental_execution_log_arg ( + set _experimental_execution_log_arg= + if not "%~1" == "" ( + set sbt_args_experimental_execution_log=%~1 + shift + goto args_loop + ) else ( + echo "%~0" is missing a value + goto error + ) + goto args_loop +) + if "%~0" == "--no-share" set _no_share_arg=true if "%~0" == "-no-share" set _no_share_arg=true @@ -724,6 +740,10 @@ if not defined sbt_args_no_hide_jdk_warnings ( ) ) +if defined sbt_args_experimental_execution_log ( + set _SBT_OPTS=-Dsbt.experimental_execution_log=!sbt_args_experimental_execution_log! !_SBT_OPTS! +) + rem TODO: _SBT_OPTS needs to be processed as args and diffed against SBT_ARGS if !sbt_args_print_sbt_version! equ 1 ( @@ -1137,6 +1157,8 @@ echo --script-version print the version of sbt script echo -d ^| --debug set sbt log level to debug echo -debug-inc ^| --debug-inc echo enable extra debugging for the incremental compiler +echo --experimental_execution_log=true^|^ +echo enable experimental execution log rem echo -J-X pass option -X directly to the java runtime rem echo ^(-J is stripped^) rem echo -S-X add -X to sbt's scalacOptions ^(-S is stripped^) diff --git a/sbt b/sbt index 33b4a2af4..2ced6ea5f 100755 --- a/sbt +++ b/sbt @@ -668,6 +668,8 @@ Usage: `basename "$0"` [options] -d | --debug set sbt log level to debug -debug-inc | --debug-inc enable extra debugging for the incremental compiler + --experimental_execution_log=true| + enable experimental execution log # sbt version (default: from project/build.properties if present, else latest release) --sbt-version use the specified version of sbt @@ -725,6 +727,7 @@ map_args () { -autostart=*) options=( "${options[@]}" "-Dsbt.server.autostart=${1:12}" ) && shift ;; --color=*) options=( "${options[@]}" "-Dsbt.color=${1:8}" ) && shift ;; -color=*) options=( "${options[@]}" "-Dsbt.color=${1:7}" ) && shift ;; + --experimental_execution_log=*) options=( "${options[@]}" "-Dsbt.experimental_execution_log=${1:29}" ) && shift ;; -no-share|--no-share) options=( "${options[@]}" "${noshare_opts[@]}" ) && shift ;; -no-global|--no-global) options=( "${options[@]}" "-Dsbt.global.base=$(pwd)/project/.sbtboot" ) && shift ;; -ivy|--ivy) require_arg path "$1" "$2" && options=( "${options[@]}" "-Dsbt.ivy.home=$2" ) && shift 2 ;; diff --git a/sbtw/src/main/scala/sbtw/ArgParser.scala b/sbtw/src/main/scala/sbtw/ArgParser.scala index 66c3eb233..5536bd563 100644 --- a/sbtw/src/main/scala/sbtw/ArgParser.scala +++ b/sbtw/src/main/scala/sbtw/ArgParser.scala @@ -44,6 +44,9 @@ object ArgParser: opt[String]("autostart").action((x, c) => c.copy(autostart = Some(x))), opt[Int]("jvm-debug").action((x, c) => c.copy(jvmDebug = Some(x))), opt[String]("java-home").action((x, c) => c.copy(javaHome = Some(x))), + opt[String]("experimental_execution_log").action((x, c) => + c.copy(experimentalExecutionLog = Some(x)) + ), arg[String]("") .unbounded() .optional() diff --git a/sbtw/src/main/scala/sbtw/LauncherOptions.scala b/sbtw/src/main/scala/sbtw/LauncherOptions.scala index 2c6aafec0..e6527eca3 100644 --- a/sbtw/src/main/scala/sbtw/LauncherOptions.scala +++ b/sbtw/src/main/scala/sbtw/LauncherOptions.scala @@ -35,6 +35,7 @@ case class LauncherOptions( server: Boolean = false, residual: Seq[String] = Nil, sbtNew: Boolean = false, + experimentalExecutionLog: Option[String] = None, ) object LauncherOptions: diff --git a/sbtw/src/main/scala/sbtw/Runner.scala b/sbtw/src/main/scala/sbtw/Runner.scala index 359effdce..9df81705c 100644 --- a/sbtw/src/main/scala/sbtw/Runner.scala +++ b/sbtw/src/main/scala/sbtw/Runner.scala @@ -63,6 +63,7 @@ object Runner: opts.ivy.foreach(v => s = s :+ s"-Dsbt.ivy.home=$v") opts.color.foreach(v => s = s :+ s"-Dsbt.color=$v") opts.autostart.foreach(v => s = s :+ s"-Dsbt.server.autostart=$v") + opts.experimentalExecutionLog.foreach(v => s = s :+ s"-Dsbt.experimental_execution_log=$v") if opts.timings then s = s ++ Seq("-Dsbt.task.timings=true", "-Dsbt.task.timings.on.shutdown=true") if opts.traces then s = s :+ "-Dsbt.traces=true"