Skip to content

Add --client default arg#17

Merged
adamw merged 3 commits into
softwaremill:masterfrom
Swiddis:feature/client-arg
Jun 16, 2025
Merged

Add --client default arg#17
adamw merged 3 commits into
softwaremill:masterfrom
Swiddis:feature/client-arg

Conversation

@Swiddis
Copy link
Copy Markdown
Contributor

@Swiddis Swiddis commented Jun 13, 2025

Newer versions of SBT support the experimental --client flag, which persists an SBT server in the background and reuses it instead of starting and tearing down a new server on every invocation. For complex projects with lots of packages/keys, this is a dramatic difference:

$ time sbt scalafmtCheckAll
...
sbt scalafmtCheckAll  36.77s user 2.98s system 570% cpu 6.962 total

$ time sbt scalafmtCheckAll --client
...
sbt scalafmtCheckAll --client  0.03s user 0.05s system 24% cpu 0.350 total

Supporting this argument in the precommit hooks will reduce commit times by several seconds for larger Scala projects.

Since the feature is still experimental and not supported on all SBT versions, I set it to disabled by default.

@Swiddis
Copy link
Copy Markdown
Contributor Author

Swiddis commented Jun 13, 2025

Tested on my dayjob's repo and it works as expected. Don't see any automated testing here.

[INFO] Initializing environment for https://github.com/Swiddis/scala-pre-commit-hooks.
[INFO] Installing environment for https://github.com/Swiddis/scala-pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
Scala unused imports (+ fatal warnings)..................................Passed
scalafmt formatting fix..................................................Passed
[precommit 9f5f52b5] Test
 1 file changed, 4 insertions(+), 4 deletions(-)

@adamw adamw merged commit 9adedc2 into softwaremill:master Jun 16, 2025
@adamw
Copy link
Copy Markdown
Member

adamw commented Jun 16, 2025

Thank you! Yes, automated tests are lacking, though I'm not sure how they could work. But if you'd have an idea, I'll be happy to merge :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants