feat(sbt): add "--server" - #37
Open
cheleb wants to merge 1 commit into
Open
Conversation
- Add `--server` flag to sbt command arguments to run sbt server in foreground. sbt 2 by default runs sbtn (thin client)
s5bug
suggested changes
Jul 6, 2026
| // Utility to invoke a given sbt task and fetch its output | ||
| function printSbtTask(task: string, cwd?: string): Promise<string> { | ||
| const args = ["--batch", "-no-colors", "-Dsbt.supershell=false", `print ${task}`]; | ||
| const args = ["--server", "--batch", "-no-colors", "-J-Dsbt.supershell=false", `print ${task}`]; |
There was a problem hiding this comment.
Not sure that the correct solution here is to use --server. If we take a look at SBT 2 output:
aly@hydrogen ~/D/d/scalajs (main)> sbt --batch -no-colors -Dsbt.supershell=false "print fullLinkJSOutput" | hexdump -C
00000000 2f 68 6f 6d 65 2f 61 6c 79 2f 44 6f 63 75 6d 65 |/home/aly/Docume|
00000010 6e 74 73 2f 64 70 66 2d 70 6c 61 79 67 72 6f 75 |nts/dpf-playgrou|
00000020 6e 64 2f 73 63 61 6c 61 6a 73 2f 74 61 72 67 65 |nd/scalajs/targe|
00000030 74 2f 6f 75 74 2f 73 6a 73 31 2f 73 63 61 6c 61 |t/out/sjs1/scala|
00000040 2d 33 2e 38 2e 34 2f 64 70 66 70 6c 61 79 67 72 |-3.8.4/dpfplaygr|
00000050 6f 75 6e 64 2f 64 70 66 70 6c 61 79 67 72 6f 75 |ound/dpfplaygrou|
00000060 6e 64 2d 6f 70 74 0a 5b 73 75 63 63 65 73 73 5d |nd-opt.[success]|
00000070 20 65 6c 61 70 73 65 64 20 74 69 6d 65 3a 20 30 | elapsed time: 0|
00000080 20 73 0a 1b 5b 30 4a | s..[0J|
00000087
There's an \x1b[0J here in the thin client that doesn't appear in the output when using --server, but otherwise the thin client's output is correct & is much faster to execute than the server.
There was a problem hiding this comment.
One solution would be to write the task output to a temporary file instead:
aly@hydrogen ~/D/d/scalajs (main) [1]> sbt --batch -no-colors -Dsbt.supershell=false 'set TaskKey[Unit]("dummy") := sbt.IO.write(file("/tmp/tmp.TFqXG6olui"), (Compile / fullLinkJSOutput).value.absolutePath);' 'dummy'
[info] Defining dummy
[info] The new value will be used by no settings or tasks.
[info] Reapplying settings...
[info] set current project to dpfPlayground (in build file:/home/aly/Documents/dpf-playground/scalajs/)
[success] elapsed time: 2 s
aly@hydrogen ~/D/d/scalajs (main)> cat /tmp/tmp.TFqXG6olui
/home/aly/Documents/dpf-playground/scalajs/target/out/sjs1/scala-3.8.4/dpfplayground/dpfplayground-opt⏎
| // Utility to invoke a given sbt task and fetch its output | ||
| function printSbtTask(task: string, cwd?: string): Promise<string> { | ||
| const args = ["--batch", "-no-colors", "-Dsbt.supershell=false", `print ${task}`]; | ||
| const args = ["--server", "--batch", "-no-colors", "-J-Dsbt.supershell=false", `print ${task}`]; |
There was a problem hiding this comment.
The -J here is incorrect, if you read sbt --help:
-Dkey=val pass -Dkey=val directly to the java runtime
-J-X pass option -X directly to the java runtime
(-J is stripped)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--serverflag to sbt command arguments to run sbt server in foreground.sbt 2 by default runs sbtn (thin client)