Improve and make sbt's workflow more opinionated
See original GitHub issuesbt is project independent. It allows users to suspend an existing sbt process in project A
, change the directory to project B
, fg
the previous sbt process, reload
, and have a working sbt for B
.
This is a great advantage:
- You only have one virtual machine running on your machine for different projects/repos.
- You reuse the hot compiler across all those different projects/repos.
- You reuse a hot sbt instance (things like
reload
andupdate
make a difference in such a case).
In the past weeks, I’ve observed people’s common sbt workflows. The most common problem I’ve seen is people killing sbt instances because of <CTRL+C>
not doing the right thing, or because they want to switch projects, or because they’ve done a change to an .sbt
file.
This is a total productivity killer.
I think the status quo could be improved via three improvements to the build tool. They should be accompanied with a new page in the docs that recommend the new workflow, if we happen to have consensus.
Workflow improvements
-
Job cancelling should never fail. The reasoning is that if it never fails, it can be enabled by default. Some of the times, jobs may be required to run in independent threads so that long-running interruptible tasks can be killed by shutting its thread down. This should:
- Handle
compile
and similar tasks gracefully. - Handle background tasks and servers gracefully (there are some problems with akka-http servers).
- Handle
-
Add a
cd
command that allows users to change the project working directory automatically. This emulates the manual<CTRL+Z>
,fg
andreload
.- Example 1:
> cd /foo/bar/projects/b
. - Example 2:
> cd ../../projects/a
. - The command autocompletes both absolute file paths and relative paths (based on the working directory).
- Example 1:
-
Watch project’s sbt files and do either of these two things:
- Reload sbt automatically.
- Warn user that the sbt files have changed, and that they should run
reload
.
This is a little bit tricky to implement, but it’s worth it. As always, this feature can be disabled via a setting, but it’ll be enabled by default.
After all these changes have been done, a new doc page should be created with the title “The recommended sbt workflow” where we recommend such a workflow and say why. This new doc page will help beginners feel productive from the very start.
These suggestions are up to discussion, and I welcome more improvements along these lines.
sbt version: 1.x
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:5 (5 by maintainers)
A relevant issue: https://github.com/sbt/sbt/issues/3252
There is a plugin for that: sbt-build-files-watcher (not sure it works with sbt-1.x). I’ve been using it for quite some time integrated with sbt-prompt to show the warning in the prompt.
sbt 1.3.0 also enables Ctrl-C.
I am going to close this issue since it’s somewhat open-ended, but feel free to bring up specific topics in https://discuss.lightbend.com/c/tooling