Commit Graph
2930 Commits
Author SHA1 Message Date
Eugene Yokota 72aff3c13c [2.x] Retire textDocument/definition 2026-08-06 14:07:35 -04:00
Eugene Yokota e23053fb89 [2.x] fix: Gate LSP calls behind auth
**Problem**
Some custom LSP calls do not check initialize-handshake,
which over TCP includes token-based authentication.

**Solution**
This adds checkAuthenticated check around sbt/exec etc.
2026-08-06 14:07:13 -04:00
BrianHotopp d0960b8fa6 [2.0.x] fix: Complete earlyOutputPing on cache-hit and failed compiles (#9542)
With usePipelining enabled, earlyOutputPing was completed only as a side
effect of zinc reporting progress mid-compile (CompileProgress.afterEarlyOutput
via writeEarlyOut / notifyNoEarlyOut in zinc-core). On an action-cache hit zinc
never runs, and on a failed compile it never reports, so the promise stayed
unfulfilled and every task waiting on it - compileEarly and makePickleProducts
across downstream pipelined projects - parked forever. A warm compile;compile
on a multi-module build hung indefinitely (#9486).

The compile task now completes the ping on every resolution path. Zinc's own
completion still wins when zinc ran (tryComplete is atomic, so it can never
pre-empt it); a cache hit completes it from the pickle jar's presence on disk
(absent jar means downstream falls back to a full compile, which is the correct
degradation); a failed compile completes it false so waiters take the full
compile path and propagate the failure instead of hanging.

Generated-by: kimi-code/k3 (Oh My Pi)
2026-08-03 16:29:01 -04:00
eugene yokota bea2a1801a [2.0.x] fix: Fixes a/build.sbt leakage (#9519)
**Problem**
subproject build.sbt like a/build.sbt leaks to siblings.

**Solution**
Don't forward freshly computed common settings unless
the build.sbt is at root.
2026-08-03 16:25:08 -04:00
eugene yokota f1e31054fe [2.x] fix: Fixes AccessDeniedException issue on Windows (#9538)
**Problem**
When test classloader holds on to the JAR file, Windows gets
AccessDefinedException on packageBin.

**Solution**
Flip the default to close the test class loader.
2026-08-03 01:01:03 -04:00
eugene yokota 3995669971 [2.x] fix: Fixes forked run baseDirectory, take 2 (#9531)
**Problem**
Forked run baseDirectory was changed to current directory in sbt 2.0.4,
which on its own is fine, but it doesn't respect
Compile / run / baseDirectory.

**Solution**
This fixes that.
2026-08-03 01:01:03 -04:00
Mai Huy HoàngandClaude Opus 5 b797f9b231 [2.0.x] perf: Stop content-hashing artifacts when writing update caches (#9524)
sjsonnew serializes a File as a (uri, Long) pair whose Long is a SHA-256 of the
file's contents, and the read direction discards it. A report names each
artifact once per configuration it resolved in, and the projects of a build
largely share their dependencies, so writing the caches re-reads the whole
downloaded classpath many times over: on a 302-module monorepo, 755 GB of jars
and about 11 minutes of CPU for bytes no reader looks at.

Staleness comes from LibraryManagement.fileUptodate instead, which checks
File.exists and the modification time against UpdateReport.stamps.

UpdateReportPersistence.CacheCodec extends the LibraryManagementCodec trait and overrides
the inherited fileStringLongIso so the pair carries 0. That member is virtual,
so the override also reaches the Vector[(Artifact, File)] nested inside the
generated ModuleReportFormat, which a locally-scoped JsonFormat[File] could
not. The inputs store keeps the stock codec, so Tracked.inputChanged still
hashes contents for invalidation.

The JSON shape is unchanged, so caches stay readable in both directions.

Co-authored-by: Claude Opus 5 <[email protected]>
2026-08-03 01:01:03 -04:00
Jozef Koval ff2a76e769 [2.0.x] fix: Make forked run inherit sbt's working directory (#9442)
forked run used the project's baseDirectory as the working directory, while non-forked execution inherits sbt's own working directory — so toggling fork silently changed how relative paths resolved.

forked run (and forked console) now inherit sbt's working directory, consistent with non-forked execution and `sbtn` expectations.
2026-07-26 15:49:44 -04:00
eugene yokota 3155bde5ab [2.0.x] fix: Fixes scalaCompilerBridgeBin (#9506)
**Problem/Solution**
Fixes scalaCompilerBridgeBin leaking project names
across different builds.
2026-07-26 15:49:44 -04:00
Eugene Yokota 30f573f1c3 [2.0.x] Move compiler bridge to Update
**Problem**
We want to grab tooling artifacts in update.

**Solution**
This adds binary compiler bridge artifacts into the update graph.
2026-07-26 15:49:44 -04:00
BrianHotoppandClaude Opus 4.8 8266803408 [2.0.x] fix: Complete server teardown before logging so reboot works from sbtn (#9497)
Running reboot in the sbt shell dropped to the OS shell instead of rebooting.
The break was in teardown: Server.shutdown opened with
log.info, and during a client-initiated reboot the terminal in scope is that
client's already-closed virtual terminal, so the log write throws
ClosedChannelException through the terminal proxy. That aborted teardown
before the portfile was deleted and the server socket closed, and the
exception was swallowed by the shutdown hook (whose own error print goes to
the same dead terminal).

Server.shutdown now completes its state cleanup (portfile, tokenfile, running
flag, server socket) before logging, and CommandExchange.shutdown wraps each
channel shutdown and the server shutdown individually so one failing step
cannot skip the rest.

Fixes #9095

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
2026-07-26 15:04:46 -04:00
Eugene Yokota aed2719f02 [2.x] fix: Intern GrpcActionCacheStore
**Problem**
GrpcActionCacheStore gets recreated per reload.

**Solution**
This interns GrpcActionCacheStore based on the parameters.
2026-07-26 15:00:58 -04:00
eugene yokota f026f09c89 [2.x] clean task cleans sona-staging (#9479)
**Problem/Solution**
1. clean task cleans sona-staging directory.
2. cleanFull calls clean task.
2026-07-25 15:56:15 -04:00
eugene yokota c12181af7f [2.x] fix: Fixes common settings with extraProjects (#9495)
**Problem**
The presence of extraProjects broke common settings.

**Solution**
This fixes it by passing finalRoot.commonSettings.
2026-07-25 15:55:52 -04:00
eugene yokota fa7065bdda [2.0.x] fix: Fixes stale resources in test (#9472)
**Problem**
sbt 2.x currently constructs the test classloader using symlinks
to the JARs in CAS (content-addressable storage).
This causes issues because JVM apparently caches opened JAR files by path,
and since the symlink itself doesn't change it could end up
serving stale resource files.

**Solution**
We can workaround this issue by resolving the symlinks to the real path.
2026-07-18 10:13:59 -04:00
Anatolii Kmetiuk c1b289c934 [2.0.x] fix sjson downgrade (#9426)
Extend metabuild exclusion to all sbt-provided deps.
2026-07-12 22:28:37 -04:00
Anatolii Kmetiuk e00efb9d9c [2.x] Fix ivyless sbt plugin publish cross paths (#9416)
Problem:
When useIvy := false, ivyless publishing dropped the optional
scala_[scalaVersion]/ and sbt_[sbtVersion]/ path segments from Ivy-style
plugin publish patterns. This caused sbt 1 plugins published from sbt 2 builds
to land under non-plugin Ivy paths, so consumers looking under
scala_2.12/sbt_1.0/ could not resolve them.

Solution:
Read the plugin cross-version attributes from the CsrProject module and use
them when constructing ivyless Ivy-layout publish paths. Apply the same
substitution for local/file Ivy publishing and remote Ivy-style URL publishing,
while continuing to omit those optional segments when the attributes are absent.
Add scripted regressions for local and HTTP Ivy-style publishing of an sbt 1
plugin with useIvy := false.
2026-07-12 22:28:10 -04:00
Anatolii Kmetiuk 7d77f44cdc Fix #9343 route pipelined dependencyPicklePath through internalDependencyPicklePath (#9425) 2026-07-12 21:28:14 -04:00
BrianHotoppandClaude Fable 5 b5ecb37ae7 [2.x] fix: Discard a cancelled task's output backlog on cancel (#9411)
A task that floods stdout could not be stopped promptly: cancelling it
(Ctrl+C from the thin client) stopped the task, but the server kept
draining the already-queued output to the client for several seconds,
because onCancellationRequest never discarded the pending backlog.

onCancellationRequest now sets a per-channel isCanceled flag and clears the
queued frames and buffered stdout (discardPending), and jsonRpcNotify
drops the cancelled task's systemOut/systemErr while the flag is set, so
output stops promptly.

Co-authored-by: Claude Fable 5 <[email protected]>
2026-07-12 21:27:57 -04:00
eugene yokota 3c350df583 [2.0.x] Tweak server startup message (#9430)
**Problem/Solution**
sbt 2.x uses client-server by default.
This makes the message a bit more obvious when the build is using a client.
2026-07-11 13:28:07 -04:00
1bfb971e2d [2.0.x] fix: Keep the output-flush timer alive across forceFlush (#9422)
NetworkChannel batches writes to the client at most once per 20ms to
reduce terminal flicker and byte volume. forceFlush(), used to order
buffered stdout ahead of a control-plane message, called
flushExecutor.shutdownNow() -- the only place the executor was ever
shut down. Once it ran during active output it tore the executor
down (and, if a coalesced flush was pending, cancelled its future
without resetting flushFuture, leaving the slot stuck), so the 20ms
coalescing was gone for the rest of the connection: stdout was then
flushed per write via the inline fallback instead of batched. Output
still reaches the client, so the effect is extra flushes rather than
lost output, but shutting the shared executor down on the first
forceFlush is clearly unintended.

Extract the flush state machine into CoalescingFlusher. forceFlush now
drains immediately and leaves the timer live (a pending coalesced
drain harmlessly drains the remainder when it fires); the executor is
shut down once, at channel teardown, so it no longer leaks. doFlush
now holds a lock across both the drain and the publish so an inline
forceFlush and the timer's drain can't deliver two stdout batches out
of order.

Fixes #9415

Co-authored-by: BrianHotopp <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
2026-07-10 16:05:25 -04:00
Yannick Heiber 27b659d584 [2.0.x] Optimize incremental test further (#9364)
This applies a range of optimisations local to ClassStamper that bring the time needed for refinedTestDigests down to acceptable levels (see #9108):
* Cache the digests of transitive dependencies (big impact)
* Avoid sorting of digest subsets that would later get sorted again (small)
* Pre-compute which Analysis instances are required for each class to avoid repeated scanning of the whole list (medium)
* Merge two loops on relations.externalDeps into one (small)
* Compute the set of extra digests outside loop (small)
* Track the digest closure of each test via a BitSet (big)
2026-06-28 20:29:23 -04:00
eugene yokota fcb37b9c7b [2.0.x] fix: Fixes global plugin loading (#9391)
**Problem**
Global plugin loading doesn't work.

**Solution**
1. Use ModuleID from to supply the location of global-plugin module.
2. Update pluginData with the global plugin classpath.
2026-06-28 20:21:28 -04:00
eugene yokotaandMatt Dziuban ddbfe9702e [2.0.x] Improve performance of ClassStamper (#9396)
- Use Builders to avoid building intermediate collections
- Use a mutable.Set for alreadySeen
- Use plain Set instead of SortedSet
  - Sorting only needs to happen at the end of the computation in transitiveStamp

Co-authored-by: Matt Dziuban <[email protected]>
2026-06-27 19:38:01 -04:00
Anatolii Kmetiuk 36aa899474 [2.0.x] Fix publishDiagnostics propagation (#9376)
**Problem**
Test is based on https://github.com/sbt/sbt/issues/9345#issuecomment-4718229113 which gives us the following sequence:

1. Metals sends buildTarget/compile.
2. sbt publishes real non-empty diagnostics.
3. Metals sends buildTarget/scalaMainClasses.
4. During that request, sbt emits build/publishDiagnostics with diagnostics: [] and reset: true.
5. The following build/taskFinish still reports errors: 1.

Previously, errors for diagnostics reporting via bsp were collected from a live compilation run. In the sequence above, that is triggered by buildTarget/compile. Then, buildTarget/scalaMainClasses does not trigger such a run for the second time, it uses the cached compilation result. Therefore, the diagnostics is not populated.

**Solution**
The proposed fix modifies sendFailureReport to accept an optional CompileFailed object that contains the diagnostics even in case the actual compiler did not run because the cached result was used. If no problems were found for a file via default means, this CompileFailed object is queried to see if it has any information about problems in a given file.
2026-06-27 18:53:40 -04:00
eugene yokota de1b5ee9ea [2.x] fix: Fixes console / javaOptions (#9324)
**Problem**
console / javaOptions is ignored.

**Solution**
1. This enables forked console even for sbt --server mode.
2. This includes console / javaOptions to the forkOptions.
2026-06-10 21:23:11 -04:00
eugene yokota f94f987f1d [2.0.x] fix: Fixes cross build caching (#9306)
**Problem**
We can get into a situation where CompileInputs2 become identical for Scala 3.x and 2.13, which breaks the recovery of Zinc analysis.

**Solution**
This includes Scala version into CompileInput2 to workaround this issue.
2026-06-07 23:50:35 -04:00
eugene yokotaandAli Rashid 65a38f0fb8 [2.0.x] fix: Fixes publishing platform-specific artifacts (like Scala Native) (#9303)
**Problem**
Platform suffix is absent in published artifacts.

**Solution**
This fixes
- Ivy backend (useIvy := true) - CrossVersion.substituteCross via IvyActions

Co-authored-by: Ali Rashid <[email protected]>
2026-06-07 21:16:14 -04:00
Eugene Yokota 001fbf8e69 [2.0.x] fix: Avoid updateFull
**Problem**
updateFull is called in no-op compile.

**Solution**
Avoid it for the default dependency mode.
2026-06-01 07:06:20 -04:00
BrianHotoppandClaude Opus 4.7 0ecc581256 [2.x] fix: Apply dependencyMode filtering to internal project deps (#9250)
Fixes #9009.

dependencyMode := DependencyMode.PlusOne strips every internal
project dependency from the compile classpath, even direct ones --
LibA/compile fails with Not found: CoreClass despite
LibA.dependsOn(Core). Direct mode happens to work today, but only by
accident (filterByDirectDeps matches against allDependencies, which
includes projectDependencies -- the bug surface is one step removed).

Root cause: ClasspathImpl.filterByPlusOne resolves the
direct-dep key set from UpdateReport, which only contains externally
resolved (LM) modules. Internal project refs never appear there, so
resolvedDirectKeys is empty for internal entries; plusOneKeys is
likewise empty; the final filter strips every internal classpath
entry whose moduleIDStr identifies an internal project. Diagnosis on
the issue by eureka0928.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
2026-06-01 06:56:33 -04:00
Anatolii Kmetiuk aed2c6125b [2.x] Opt bspBuildTargetOutputPathsItem out of caching (#9272)
Opt bspBuildTargetOutputPathsItem out of caching
2026-06-01 04:14:18 -04:00
eugene yokota 2ba33f3ff4 Merge pull request #9284 from eed3si9n/bport2/bump-sjsonnew
[2.0.x] bport: sjson-new 0.15.0
2026-06-01 03:13:50 -04:00
eugene yokota 09aca71007 [2.0.x] perf: Improve incremental test stamper (#9257) (#9283)
**Problem**
Incremental stamper is still causing perf issue.

**Solution**
This further avoids SHA-256 calls to calculate the stamp.
2026-06-01 02:58:25 -04:00
Eugene Yokota 82bb44d543 [2.0.x] Contraband 0.9.0 2026-06-01 02:23:15 -04:00
Eugene Yokota f1c914f4ae [2.x] Reimplement FarmHash
**Problem**
sbtn and server uses FarmHash.

**Solution**
This reimplements FarmHash using Scala.
2026-05-31 16:57:12 -04:00
eugene yokota ae1192109d [2.0.x] ci: Scalafmt 3.11.1 (#9280)
Apply Scalafmt
2026-05-31 16:30:32 -04:00
eugene yokotaandAnatolii Kmetiuk e6666e4b10 [2.0.x] Fix duplicate autoplugins packageBin mappings (#9255) (#9273)
Deduplicate executable jar package entries. In the issue, the duplicate was something like:

(resource_managed/.../sbt/sbt.autoplugins, "sbt/sbt.autoplugins")
(classes/.../sbt/sbt.autoplugins,          "sbt/sbt.autoplugins")

This is because copyResources copied autoplugin metadata to the classes directory.

Solution: when composing the packageBinMappings, differentiate between artifacts that come from class directory and from outside of it. If there is a duplicate, prefer resource that comes from outside of it.

Co-authored-by: Anatolii Kmetiuk <[email protected]>
2026-05-30 20:16:58 -04:00
Anatolii Kmetiuk afac251f28 [2.x] fix: Include platform suffix in Artifact.artifactName (#9118) 2026-05-20 09:53:50 +09:00
eugene yokota fc15e03c33 [2.0.x] feat: Execution log (#9203)
**Problem**
We need some tooling to debug caching issues.

**Solution**
This adds an exeprimental execution log support,
which shows input and output of cached tasks.
2026-05-17 03:34:20 -04:00
bitloi 217e0091f9 [2.x] fix: sbt -debug doesn't display loading log (#8819)
* Fix #4979: apply -debug (and other level options) at startup so loading shows debug log

- Parse log level from configuration.arguments in StandardMain.initialState
- Pass initialLevel to GlobalLogging.initial so console appender uses it from first log
- Set Keys.logLevel and BasicKeys.explicitGlobalLogLevels in initial state when level option present
- Add initialLevel parameter to GlobalLogging.initial (default Level.Info) for backward compatibility
- Add InitialLogLevelSpec tests for logLevelFromArguments
- Add docs/fix-4979-manual-verification.md for manual reproduction
2026-05-17 03:29:25 -04:00
Dream ecfbbba389 [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-05-17 03:17:12 -04:00
Eugene Yokota c92ac232c0 Additional parens 2026-05-17 00:51:41 -04:00
kenji yoshida 3c64021190 [2.0.x] Scala 3.8.3 (#8997) 2026-05-17 00:13:13 -04:00
eugene yokota a5bf75354b [2.0.x] fix: Include test arg into hash (#9231)
**Problem**
test -- foo passes on MUnit, allowing failing tests to be validated.

**Solution**
Include test args into the cache input.
2026-05-16 04:55:35 -04:00
eugene yokota a8175c631c [2.0.x] fix: Invalidate on JDK version (#9218)
**Problem**
sbt 2.x caching doesn't invalidate on JDK version.

**Solution**
Invalidate on JDK version.
2026-05-14 22:40:00 -04:00
Eugene Yokota b1eb5600d1 Remove tests that checks for the iteration 2026-05-14 01:36:03 -04:00
Eugene Yokota 0712811dff [2.0.x] Cache analysis using file last modified
**Problem**
Current MixedAnalyzingCompiler analysis cache caches using the last write,
assuming all writing happens via it. However, this doesn't work with
sbt 2.x caching system where the gz file under it can switch.

**Solution**
This switches to using caffeine caching, which includes file size
and file timestamp for local analysis caching.
2026-05-14 01:35:39 -04:00
Matt Dziuban 02845c57f7 [2.x] fix: Use rootPaths to replace virtual paths in console and doc scalac options. (#9110)
Rather than using the FileConverter to replace virtual paths, this uses the rootPaths directly. It only replaces a virtual path in a scalac option if the given segment of the option begins with the root path key.
2026-05-03 21:29:55 -04:00
corevibe555 2b0ef70a26 [2.x] Fix: strip pipelining scalacOptions before launching the REPL (#8986)
**Problem**
When usePipelining := true in a multi-project build, sbt appends  
-Ypickle-java and -Ypickle-write <path>/early.jar to scalacOptions 
for fast parallel compilation. These flags were being leaked into the Scala  
REPL, causing failure on console

**Solution**
Strip pipelining flags before forwarding to the REPL  in Deafults.scala.
2026-05-03 21:21:52 -04:00
eugene yokota 700657451e Merge pull request #9171 from eed3si9n/bport/raw
[2.0.x] bport: ClassLoaderStrategy.Raw + forked test classpath
2026-05-03 12:37:17 -04:00