Commit Graph
472 Commits
Author SHA1 Message Date
bitloi 936a7e1ffb [2.x] fix: clear compiler bridge zinc cache on reboot dev (#9057)
Reboot dev now removes zinc/org.scala-sbt under the resolved global zinc
directory (same layout as ZincComponentManager secondary cache).

Closes #5735
2026-04-13 04:28:43 -04:00
eugene yokota 25dd9b7363 [2.x] fix: Fixes client-side run status (#9081)
**Problem**
In sbt 2.x, if we execute a run task from the shell,
and if the program fails, it ends up taking down the entire shell
because client-side run rethrows, which is not desirable
for the sbt shell.

**Solution**
1. Omit printing out success for ClientJobParams, which is the runinfo.
2. Print out success or error on the client-side for shell usage case.
2026-04-13 00:41:35 -04:00
BrianHotoppandClaude Opus 4.6 d765ba263a [2.x] fix: Return JSON-RPC error for unknown server methods (#9002)
The fallback ServerHandler silently dropped requests with unknown
methods, violating the JSON-RPC spec. Clients like Metals that send
unrecognized requests would never receive a response, potentially
causing timeouts or hangs.

Return a -32601 (Method not found) error response instead.

---------

Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
2026-04-10 01:33:20 -04:00
Dream 544f56695a [2.x] feat: Add cacheVersion setting for global cache invalidation (#8993)
* [2.x] feat: Add cacheVersion setting for global cache invalidation

**Problem**
There was no escape hatch to invalidate all task caches when needed.

**Solution**
Add `Global / cacheVersion` setting that incorporates into the cache key
hash. Changing it invalidates all caches. Defaults to reading system
property `sbt.cacheversion`, or else 0L. When 0L, the hash is identical
to the previous behavior (backward compatible).

Fixes #8992

* [2.x] refactor: Simplify BuildWideCacheConfiguration and add cacheVersion test

- Replace auxiliary constructors with default parameter values
- Add unit test verifying cacheVersion invalidates the cache

* [2.x] fix: Restore auxiliary constructors for binary compatibility

* [2.x] test: Improve cacheVersion scripted test and add release note

- Scripted test now verifies cache invalidation via a counter
  that increments only when the task body actually executes
- Add release note documenting the cacheVersion setting
2026-04-01 11:23:10 +09:00
Daniil Sivak 9939666a33 [2.x] fix: server-test and related refactoring (#8904)
- TestServer was replaced with ServerSession class, which is located in protocol module and allows you to interact with JSON-RPC sbt server.
2026-03-21 23:45:37 -04:00
BitToby be305eb3a5 fix: Use sbt script in BSP config instead of hardcoded Java path (#8920)
**Problem**

sbt bspConfig writes the absolute path of the current Java binary into .bsp/sbt.json. When the user switches Java versions (via sdkman, cs java, etc.) or removes that JDK, the IDE fails to start the sbt BSP server because the hardcoded path is stale or gone.

**Solution**

When an sbt launcher script is available (via `sbt.script` system property or PATH lookup), generate:

"argv": ["/path/to/sbt", "bsp"]
2026-03-19 20:57:53 -04:00
DreamandClaude Opus 4.6 dc90f160df [2.x] feat: Support --autostart=false and --no-server in sbtn client (#8895)
**Problem**
When sbtn (native thin client) can't find a running sbt server, it prompts
to start one. There was no way to opt out of server auto-start from the
client side, which is needed for CI environments and scripting (sbt/sbt#7079).

**Solution**
Reuse the existing sbt.server.autostart system property in NetworkClient
to control whether sbtn should attempt to start a server. When no server is
running and sbt.server.autostart=false, sbtn exits with an error instead
of prompting.

Support setting this property via:
- sbtn --no-server compile (sets sbt.server.autostart=false)
- sbtn --autostart=false compile (new flag following sbt conventions)
- sbtn -Dsbt.server.autostart=false compile (direct system property)
- sbt --autostart=false compile (bash runner and sbtw)

This follows sbt's naming conventions for properties/options: positive
property names with =false opt-out (like --color=false, --supershell=false).

Fixes sbt/sbt#7079

Co-authored-by: Claude Opus 4.6 <[email protected]>
2026-03-12 20:51:07 -04:00
kenji yoshida 963e38256c [2.x] ci: Update java file formatter plugin (#8892) 2026-03-10 11:19:48 -04:00
chrisrock1124 dd66216309 [2.x] fix: sbt --client fails if -mem is provided (#8831)
The bash launcher's runNativeClient() passed all original CLI args to
sbtn, only stripping --client. This caused sbtn to receive launcher
flags like -mem 10000, which NetworkClient.parseArgs() misclassified:
-mem went to sbtArguments and 10000 went to commandArgs, resulting in
a broken server start command.
2026-03-05 01:30:03 -05:00
Dream 8d9a0027e2 [2.x] fix: Print server stderr on startup failure (#8816)
**Problem**
When the sbt server fails to start (e.g. wrong JDK version), the client
only shows "failed to connect to server" hiding the actual error. The
server stderr is redirected to /dev/null to prevent Linux pipe buffer
deadlocks (#8442), so diagnostic output is lost.

**Solution**
Redirect server stderr to a temp file instead of /dev/null. When the
server fails to start (portfile never appears), read and print the temp
file contents before throwing ServerFailedException. The temp file is
cleaned up eagerly on both success and failure paths.

Fixes #8812
2026-02-26 00:31:09 -05:00
bitloi 130a332100 [2.x] feat: sbtn subscription level (#8796)
Closes #4399

- Add subscribeToAll to InitializeOption (protocol); default true for backward compatibility.
- CommandExchange: send broadcast notifyEvent/logMessage only to channels with subscribeToAll.
- TestServer: support subscribeToAll parameter for tests; AbstractServerTest: subscribeToAllForTest.
- ClientSubscriptionTest: assert default client receives build/logMessage when command runs.
- Scripted test server/client-subscription: run show name to exercise server client path.
2026-02-24 21:46:37 -05:00
Eve 44b9ca7c2d [2.x] feat: client-side run env inheritance (#8752)
merge current env into client-side run env
2026-02-17 14:07:54 -05:00
eugene yokota edd7061f15 [2.x] Minimalist console (#8722)
**Problem**
Forked console currently pulls in full Zinc, which includes JLine.

**Solution**
This implements a lighter-weight, full Java ForkConsoleMain,
which no longer depends on JLine.
2026-02-09 10:55:44 -05:00
bitloi d633de5c3f [2.x] fix: Detect alias/task key name conflicts (#8659)
Problem
When a user defines an alias with a name that matches an existing task or setting key (e.g., `alias c = compile` when a custom task `c` exists), the alias silently wins and shadows the task.

Solution
Detect conflicts at alias creation time and fail with an error message:
```
Alias 'c' conflicts with a task or setting key of the same name. Use a different alias name to avoid ambiguity.
```
2026-01-31 17:56:42 -05:00
Dream a5f915bf87 [2.x] test: Migrate ClassLoaderCacheTest to verify.BasicTestSuite (#8534) 2026-01-19 17:13:21 -05:00
E.G 0ec5144a63 [2.x] test: Migrate parser specs to verify.BasicTestSuite (#8551)
Migrate the following test files from ScalaTest's AnyFlatSpec to
verify.BasicTestSuite, following the pattern established by other
test files in the sbt codebase:

- SizeParserSpec.scala (util-complete)
- MultiParserSpec.scala (main-command)

Changes in all files:
- Replace AnyFlatSpec class with BasicTestSuite object
- Convert 'should ... in' syntax to 'test(...)' syntax
- Use Scala 3 syntax with colon indentation
- Add 'end' markers
- Add explicit types where needed

Related to the ongoing test migration effort.
2026-01-18 14:33:04 -05:00
bitloi c832fad7b5 [2.x] feat: Notify sbtn client when command is queued (#8568)
Fixes #8356

**Problem**

When `sbtn` sends a command while another long-running task (like `console`) is already executing, the client silently blocks with no indication that the command is waiting in a queue.

**Solution**

When a new command arrives via the network channel and another command is currently running, the server now sends an `ExecStatusEvent` notification with status `"Queued"` to the client. The client displays a message like:

```
[info] waiting for: console
```
2026-01-16 16:17:00 -05:00
eugene yokota 4d7e0633a8 Revert "[2.x] feat: Enable musl static linking for sbtn on JDK 17+ (#8464)" (#8557)
This reverts commit e16298521b.
2026-01-16 00:06:28 -05:00
aka James4u dce915e794 [2.x] fix: Error "Exception in thread "sbt-socket-server" java.lang.NullPointerException" on exit (#8448)
Fixes #8538

The code was calling e.getMessage.contains() without checking if getMessage()
returns null. Changed to use Option(e.getMessage).exists() to safely handle
null values.
2026-01-15 11:06:51 -05:00
MkDev11 e16298521b [2.x] feat: Enable musl static linking for sbtn on JDK 17+ (#8464)
** Problem **

The sbtn (sbt thin client) native image on Linux currently depends on glibc because ipcsocket uses JNI for Unix domain sockets. When building with musl for static linking, the JNI library fails to load since musl doesn't support `dlopen`.

** Solution **

Instead of upgrading to ipcsocket 2.x (which isn't ready for production), I created a `UnixDomainSocketFactory` that detects JDK 17+ at runtime and uses the native `java.net.UnixDomainSocketAddress` API directly via reflection. This completely bypasses JNI on modern JDKs.

For older JDKs (8 and 11), the factory falls back to ipcsocket 1.6.3, which is stable and well-tested.

** How It Works **

The factory checks at startup whether `java.net.UnixDomainSocketAddress` is available:

- **JDK 17+**: Uses native NIO Unix domain sockets (no JNI, no native libraries)
- **JDK 8/11**: Falls back to ipcsocket's JNI-based implementation

This approach:
- Enables musl static linking on JDK 17+ without any native dependencies
- Maintains full backward compatibility with older JDKs
- Keeps the stable ipcsocket 1.6.3 instead of the unstable 2.x
2026-01-13 23:14:45 -05:00
Match 88e2f2704f [2.x] fix: Fixes --no-colors setting for sbtn (#8517) 2026-01-13 14:44:09 -05:00
MkDev11 add43bd230 feat: Set terminal window title when running applications (#8492)
Set window title to 'sbt <command>: <org> % <name> % <version>' when
running sbt run, runMain, bgRun, or bgRunMain.

For server-side runs, window title is set directly. For client-side runs (sbtn), window title is passed via RunInfo protocol
and set by NetworkClient.

Fixes #7586
2026-01-12 02:32:52 -05:00
calm329 476730aba2 fix: Prevent server subprocess hang on Linux (#8442) 2026-01-11 21:00:57 -08:00
xuwei-k c0fe4dfb10 Add tailrec annotation 2026-01-11 16:33:45 +09:00
Martin Duhem 37037357a3 Fix help command arguments parsing
Previously, some additional code was used to parse the arguments to the
`help` command and ensure that the remaining commands were consistent
with the desired state of sbt.

While this code worked well in sbt 1.x, and was helpful in getting `sbt
help new` to work as expected, this does not work in sbt 2, and is
actually not required.

This patch removes the additional code, which fixes the `help` command
in sbt.
2025-12-18 17:49:32 +01:00
Eugene Yokota d1e0a5a35d cleanFull 2025-11-23 14:45:21 -05:00
Eugene Yokota c8edb171ee [2.x] Adds cleanExpunge command
**Problem**
We might want to clear the disk cache.

**Solution**
This adds cleanExpunge command.
2025-11-22 23:12:18 -05:00
Eugene Yokota 4265b92aa4 perf: Cache content hash of binary files
**Problem**
sha256 is currently a bottleneck for no-op compilation.

**Solution**
This adds a local, in-memory cache of sha256 hashes of binary files
using their timestamp and file size.
The size of the digest cache can be configured using localDigestCacheByteSize,
which is set to 1MB by default.
2025-11-11 15:59:42 -05:00
Eugene Yokota 645908f597 Apply Contraband 2025-09-28 21:28:21 -04:00
xuwei-k 1a882b0dc3 remove some format: off comments 2025-09-24 18:49:30 +09:00
Eugene Yokota 2fa3159f18 Update to Contraband 0.8.0 2025-09-19 00:46:34 -04:00
Eugene Yokota 9783cd092b Merge branch '1.11.x' into wip/merge-1.11.x 2025-08-25 02:29:12 -04:00
Eugene Yokota ff328a092d Improve sbtn a bit
1. Remove experimental warning.
2. Buffer the boot log so ANSI output is fixed for JVM client.
3. Remove timestamp.
2025-08-24 03:58:13 -04:00
Eugene Yokota 3b4547718e Remove deprecated methods 2025-05-11 05:23:41 -04:00
Eugene Yokota 8db8c79d33 Implement client-side run
**Problem**
`run` task has been emulated via function call inside of a sandboxed classloader,
and blocking the command processing of sbt server loop.
This poses isolation and availability issues.

**Solution**
This implements client-side run where the server creates a sandbox environment, and sends the information to the client,
and the client forks a new JVM to perform the run.
The client-side behavior has been implemented in sbtn side already.
2025-03-09 15:00:24 -04:00
Eugene Yokota 2c3c0f4a7c Merge branch '1.10.x' into wip/merge-1.10.x 2025-03-08 19:05:30 -05:00
Eugene Yokota 9d4cc80a80 Shortcut sbtn shutdown
**Problem**
WHen portfile is not found, sbtn will try to start the server
even when the desired command is shutdown.

**Solution**
When the command is just shutdown, don't start the server.
2025-03-05 02:27:46 -05:00
Eugene Yokota 67265638c6 Implement client-side run
**Problem**
`run` task blocks the server, but during the run the server is just
waiting for the built program to finish.

**Solution**
This implements client-side run where the server creates a sandbox
environment, and sends the information to the client,
and the client forks a new JVM to perform the run.
2025-03-02 20:45:04 -05:00
xuwei-k 5d660ab8b5 remove unnecessary case
- https://github.com/xuwei-k/scalafix-rules/blob/3ca36335057154ef4431fee464a86b721013d334/rules/src/main/scala/fix/RemoveParameterUntuplingCase.scala
- https://docs.scala-lang.org/scala3/reference/other-new-features/parameter-untupling.html
- https://docs.scala-lang.org/scala3/reference/other-new-features/parameter-untupling-spec.html
2025-02-22 08:48:29 +09:00
Eugene Yokota cb63de6574 Merge branch '1.10.x' into wip/merge-1.10.x 2025-02-10 02:43:30 -05:00
Eugene Yokota a75e847a08 refactor: Refactor response handler
**Problem**
The sbtn response handling code is relatively stragightforward,
but it's a bit messy.

**Solution**
This cleans it up a bit, similar to the style used by Unfiltered
back then (not sure how Unfiltered plans are written nowadays) by
expressing each event handling as a partial function, and composing them
together using `orElse`.
2025-02-09 18:17:02 -05:00
Josh Soref 613eb86447 Spelling (#8028)
* spelling: 1.x

Signed-off-by: Josh Soref <[email protected]>

* spelling: a

Signed-off-by: Josh Soref <[email protected]>

* spelling: aether

Signed-off-by: Josh Soref <[email protected]>

* spelling: anymore

Signed-off-by: Josh Soref <[email protected]>

* spelling: artifact

Signed-off-by: Josh Soref <[email protected]>

* spelling: available

Signed-off-by: Josh Soref <[email protected]>

* spelling: be

Signed-off-by: Josh Soref <[email protected]>

* spelling: bridge

Signed-off-by: Josh Soref <[email protected]>

* spelling: cannot

Signed-off-by: Josh Soref <[email protected]>

* spelling: case-insensitive

Signed-off-by: Josh Soref <[email protected]>

* spelling: checksum

Signed-off-by: Josh Soref <[email protected]>

* spelling: class loads

Signed-off-by: Josh Soref <[email protected]>

* spelling: contra

Signed-off-by: Josh Soref <[email protected]>

* spelling: dependencies

Signed-off-by: Josh Soref <[email protected]>

* spelling: dependency

Signed-off-by: Josh Soref <[email protected]>

* spelling: dependent

Signed-off-by: Josh Soref <[email protected]>

* spelling: deriveds

Signed-off-by: Josh Soref <[email protected]>

* spelling: describes

Signed-off-by: Josh Soref <[email protected]>

* spelling: early

Signed-off-by: Josh Soref <[email protected]>

* spelling: enclosed

Signed-off-by: Josh Soref <[email protected]>

* spelling: evaluation

Signed-off-by: Josh Soref <[email protected]>

* spelling: excluding

Signed-off-by: Josh Soref <[email protected]>

* spelling: execution

Signed-off-by: Josh Soref <[email protected]>

* spelling: for

Signed-off-by: Josh Soref <[email protected]>

* spelling: frequently

Signed-off-by: Josh Soref <[email protected]>

* spelling: github

Signed-off-by: Josh Soref <[email protected]>

* spelling: green

Signed-off-by: Josh Soref <[email protected]>

* spelling: https://www

Signed-off-by: Josh Soref <[email protected]>

* spelling: https

Signed-off-by: Josh Soref <[email protected]>

* spelling: in-sourcing

Signed-off-by: Josh Soref <[email protected]>

* spelling: include

Signed-off-by: Josh Soref <[email protected]>

* spelling: incompatible

Signed-off-by: Josh Soref <[email protected]>

* spelling: indefinitely

Signed-off-by: Josh Soref <[email protected]>

* spelling: information

Signed-off-by: Josh Soref <[email protected]>

* spelling: inputted

Signed-off-by: Josh Soref <[email protected]>

* spelling: just

Signed-off-by: Josh Soref <[email protected]>

* spelling: lastmodifiedtimes

Signed-off-by: Josh Soref <[email protected]>

* spelling: latest

Signed-off-by: Josh Soref <[email protected]>

* spelling: manifest

Signed-off-by: Josh Soref <[email protected]>

* spelling: miscellaneous

Signed-off-by: Josh Soref <[email protected]>

* spelling: more

Signed-off-by: Josh Soref <[email protected]>

* spelling: neither

Signed-off-by: Josh Soref <[email protected]>

* spelling: never

Signed-off-by: Josh Soref <[email protected]>

* spelling: nonexistent

Signed-off-by: Josh Soref <[email protected]>

* spelling: opted

Signed-off-by: Josh Soref <[email protected]>

* spelling: outputting

Signed-off-by: Josh Soref <[email protected]>

* spelling: params

Signed-off-by: Josh Soref <[email protected]>

* spelling: performance

Signed-off-by: Josh Soref <[email protected]>

* spelling: preceding

Signed-off-by: Josh Soref <[email protected]>

* spelling: presentation

Signed-off-by: Josh Soref <[email protected]>

* spelling: project

Signed-off-by: Josh Soref <[email protected]>

* spelling: projects

Signed-off-by: Josh Soref <[email protected]>

* spelling: protocol

Signed-off-by: Josh Soref <[email protected]>

* spelling: related

Signed-off-by: Josh Soref <[email protected]>

* spelling: representation

Signed-off-by: Josh Soref <[email protected]>

* spelling: res

Signed-off-by: Josh Soref <[email protected]>

* spelling: resolverlist

Signed-off-by: Josh Soref <[email protected]>

* spelling: resolverset

Signed-off-by: Josh Soref <[email protected]>

* spelling: response

Signed-off-by: Josh Soref <[email protected]>

* spelling: returned

Signed-off-by: Josh Soref <[email protected]>

* spelling: sbt_version

Signed-off-by: Josh Soref <[email protected]>

* spelling: scalacheck

Signed-off-by: Josh Soref <[email protected]>

* spelling: sentinels

Signed-off-by: Josh Soref <[email protected]>

* spelling: separates

Signed-off-by: Josh Soref <[email protected]>

* spelling: serves

Signed-off-by: Josh Soref <[email protected]>

* spelling: should

Signed-off-by: Josh Soref <[email protected]>

* spelling: significant

Signed-off-by: Josh Soref <[email protected]>

* spelling: specifically

Signed-off-by: Josh Soref <[email protected]>

* spelling: substitute

Signed-off-by: Josh Soref <[email protected]>

* spelling: suppress

Signed-off-by: Josh Soref <[email protected]>

* spelling: terminal

Signed-off-by: Josh Soref <[email protected]>

* spelling: the

Signed-off-by: Josh Soref <[email protected]>

* spelling: title

Signed-off-by: Josh Soref <[email protected]>

* spelling: transitive

Signed-off-by: Josh Soref <[email protected]>

* spelling: version

Signed-off-by: Josh Soref <[email protected]>

* spelling: versions

Signed-off-by: Josh Soref <[email protected]>

* spelling: want

Signed-off-by: Josh Soref <[email protected]>

* spelling: wanting

Signed-off-by: Josh Soref <[email protected]>

* spelling: whether

Signed-off-by: Josh Soref <[email protected]>

* link: sbt Cached Resolution

Signed-off-by: Josh Soref <[email protected]>

* link: Testing sbt plugins

Signed-off-by: Josh Soref <[email protected]>

---------

Signed-off-by: Josh Soref <[email protected]>
2025-02-04 01:11:28 -05:00
Josh Soref 2ee5eb7fa7 Make timing outputs consistently show hours and hint at time format
Signed-off-by: Josh Soref <[email protected]>
2025-01-29 04:20:37 -05:00
Josh Soref 0493dee315 Make timing outputs consistently show hours and hint at time format
Signed-off-by: Josh Soref <[email protected]>
2025-01-27 12:42:53 -05:00
xuwei-k 13d6626564 update .scalafmt.conf. enforce new scala 3 syntax 2025-01-02 11:25:34 +09:00
xuwei-k f255c38892 use toIntOption instead of scala.util.Try 2024-12-30 13:13:53 +09:00
Eugene Yokota 3d86f30837 Merge branch '1.10.x' into wip/merge-1.10.x 2024-12-16 03:20:10 -05:00
friendseeker fae2bcc01b Add documentation & deduplicate implementation 2024-10-29 21:40:51 -07:00
Friendseeker 92d4cfa690 Replace nnbsp with regular space 2024-10-29 17:43:33 -07:00
Friendseeker 828dc04808 Migrate all usages of System.console == null 2024-10-28 18:25:16 -07:00