Commit Graph

3900 Commits

Author SHA1 Message Date
eugene yokota 6d512c6ffa [2.0.x] perf: Improve incremental test stamper (#9257)
**Problem**
Incremental stamper is still causing perf issue.

**Solution**
This further avoids SHA-256 calls to calculate the stamp.
2026-06-01 02:18:42 -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 yokota 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 <anatoliykmetyuk@gmail.com>
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
eugene yokota 532edd1716 [2.x] feat: ClassLoaderStrategy.Raw (#9161)
**Problem**
In sbt 2.x, forking still creates layered classloader in the worker process,
which doesn't work for some tests.

**Solution**
This provides an escape hatch to emulate the sbt 1.x semantics of
using the system classpath for testing.
2026-05-03 01:01:41 -04:00
eugene yokota 604d2ce129
[2.0.x] fix: Fix build.sbt file loading in subdirs (#9165) (#9168)
**Problem**
Projects defined in subdirectory build.sbt files are
not correctly resolved to the base directory relative to the file.

**Solution**
Call resolveBase.
2026-05-03 00:09:27 -04:00
Matt Dziuban 6e7565d28a [2.x] Fix console output not appearing with bgRun and run / fork := true (#9166)
Bug 1: bgRun forks with inheritIO() instead of LoggedOutput

bgRunTask / bgRunMainTask resolve their fork options via (run / forkOptions), which inherits run / connectInput := true. That has two downstream consequences:

1. ForkRun.configLogged (in run/src/main/scala/sbt/Run.scala) skips installing OutputStrategy.LoggedOutput(log) whenever config.connectInput == true.
2. Fork.apply (in run/src/main/scala/sbt/Fork.scala) sees connectInput && outputStrategy == StdoutOutput and takes the interactiveFork path, which calls jpb.inheritIO().

Bug 2: Background-job log relay drops messages after the spawning task ends

Even after Bug 1 is fixed, LoggedOutput routes the forked process's stdout into the background ManagedLogger, whose appenders include a shared RelayAppender. The relay calls CommandExchange.logMessage(event), which uses isChannelOwner(c) to pick the target channel.
2026-05-02 21:40:09 -04:00
bitloi a259262262 [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-05-02 21:39:45 -04:00
Eugene Yokota 9bc47864fe [2.0.x] fix: Remove will-be-ignored warning 2026-05-02 21:30:28 -04:00
Renzo 9018c5a718 [2.x] feat: support passing JVM arguments via -- delimiter in run commands (#8868)
Summary
- Adds support for passing JVM arguments inline to `run`, `runMain`, `bgRun`, `bgRunMain`, and `fgRun`/`fgRunMain` using `--` as a delimiter
- Syntax: `run <jvmArgs> -- <appArgs>` (e.g., `run -Xmx2G -Dapp.mode=debug -- arg1 arg2`)
- Fully backward compatible — without `--`, all arguments are treated as app args as before
- When `fork` is `false`, a warning is logged that JVM arguments will be ignored
2026-05-02 21:29:42 -04:00
eugene yokota 5fe73c82fd
[2.x] perf: Use bytecodeHash for incremental test (#9152)
**Problem**
There's perf issue building ClassStamp for the incremental test.

**Solution**
This reuses the bytecodeHash created during compilation.
2026-04-29 23:10:59 -04:00
eugene yokota ec497c38ca
[2.0.x] fix: Remove will-be-ignored warning (#9144)
**Problem**
run warns about jvm option not being applied,
but it is applied for client-side run.

**Solution**
Remove the warning.
2026-04-27 04:14:12 -04:00
eugene yokota d59a2be85a [2.x] refactor: Replace string Array with ju.List (#9138)
**Problem**
Scala 3 supposedly has problem with String array in structural types.

**Solution**
This works around the issue by using ju.List.
2026-04-27 00:40:45 -04:00
Ali Rashid 30aded8ced [2.x] feat: Expose `scripted / excludeFilter` and `scripted / includeFilter` keys for scripted test filtering. (#9131)
* [2.x] feat: Add scripted / includeFilter and scripted / excludeFilter

* [2.x] Add scripted-exclude-filter scripted test. Remove stale item from Scripted.sbtWindowsExcludeFilter
2026-04-27 00:40:03 -04:00
eugene yokota 56c3fdbd0b
[2.0.x] fix: Fixes compilerPlugin(...) to ignore platform (#9135) (#9136)
**Problem**
When using scala-native, we can't enable semanticdb etc
because of the platform-level platform.

**Solution**
Since compilerPlugin(...) is always going to be JVM,
just add an explicit JVM platform to the given ModuleID.
2026-04-26 19:03:55 -04:00
eugene yokota 03c371db5e
[2.0.x] Add Test configuration to evictionWarningOptions (#9134)
* Add Test configuration to evictionWarningOptions
* Add Test configuration to default evictionWarningOptions
* Deduplicate eviction errors based on callers.
* Update eviction error test for semantic versioning.
* Group evictions by configuration and update test.

Co-authored-by: Zainab Ali <zainab.ali.london@gmail.com>
2026-04-26 13:37:00 -04:00
eugene yokota 9e2cc51579
[2.0.x] fix: Fixes managedScalaInstance false support (#9121) (#9124)
**Problem**
When managedScalaInstance is set to false, we stopped creating
ScalaInstance, but the documentation says the user can
pull in their own dependencies.

**Solution**
Attempt to construct a ScalaInstance from update report
even when managedScalaInstance is set to false.
2026-04-23 03:19:20 -04:00
eugene yokota e8757c85e2 [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:45:39 -04:00
BitToby e64db7927c [2.x] fix: stack traces suppressed in thin client batch mode (#9058)
In sbt 2.x, running batch commands through the thin client (sbtn) suppresses stack traces for all tasks because the server's shell command unconditionally sets state.interactive = true. This causes LogManager.defaultTraceLevel to return -1 (suppressed) even when the client explicitly signals non-interactive (batch) mode via Attach(interactive=false).

This fixes the shell command to check the originating NetworkChannel's interactive flag before setting state.interactive, so thin client batch commands correctly get Int.MaxValue trace level and display full stack traces.
2026-04-13 00:45:09 -04:00
Matthias Kurz e515decfc5
[2.x] add no-op addDependencyTreePlugin shim for migration (#9067) 2026-04-12 14:02:05 -04:00
eugene yokota 879ef86567
[2.0.x] fix: Scope dependencyMode filtering to compilation only (#8990) (#9074)
**Problem**
When dependencyMode := Direct is set, the filtering was applied at
the managedClasspath level, which removed transitive dependencies
from all downstream classpaths including Test / dependencyClasspath.
This caused runtime test failures because transitive deps like
hamcrest-core (pulled in by junit) were missing.

**Solution**
Move the dependencyMode filtering from managedClasspath to a new
filteredDependencyClasspath task, and wire dependencyPicklePath
(the classpath used by the compiler) to use it. Runtime classpaths
like dependencyClasspath and fullClasspath remain unfiltered,
preserving all transitive dependencies for test execution.

Fixes #8989

Co-authored-by: Dream <42954461+eureka928@users.noreply.github.com>
2026-04-12 06:25:55 -04:00
eugene yokota 542591ea20
[2.0.x] Remove Path type from caching (#9036)
**Problem**
Like File, Path normally captures the absolute path,
so likely not a good candidate for caching.

**Solution**
Ban it.

---------

Co-authored-by: Anatolii Kmetiuk <anatoliikmt@proton.me>
2026-04-06 23:10:27 -04:00
eugene yokota 91be1a2f7e
[2.x] fix: resolve virtual path in -Ypickle-write scalac option (#9011) (#9035)
earlyOutput is a virtual file reference, so passing it directly via
.toString produces a virtual path that scalac cannot resolve. Use
fileConverter.value.toPath() to convert it to an actual filesystem path.

Co-authored-by: corevibe555 <45244658+corevibe555@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 23:09:13 -04:00
eugene yokota 75edb0afe0 [2.0.x] fix: Fixes metabuild reloading (#9019)
**Problem**
There seems to be multiple problems around metabuild reloading (reload plugins).

1. Originally reported issue 9006 states that the build can't come back
   from reload plugins.
2. During the course of fixing, I discovered that when reload plugins is used
   the project name is set to "project" instead of foo-build etc.
3. Also there was a bug in the rootPaths when reload plugins is used,
   which results in class not defined error.

**Solution**
1. Fix the plugin context so reload plugin still behaves like a metabuild.
2. Fix the rootPaths.
2026-04-05 22:02:21 -04:00
eugene yokota c89f14caa1 [2.x] fix: Fixes pollInterval (#9020)
**Problem/Solution**
checkBuildSources / pollInterval should just fallback to some value.
2026-04-05 22:01:44 -04:00
eugene yokota 872985dcf4
[2.0.x] Fixes the source dependency fix (#8982)
**Problem/Solution**
Run was missing cwd.
2026-03-25 01:17:11 -04:00
eugene yokota 1d77704ea3
[2.0.x] feat: Add dependencyMode setting to control classpath transitivity (#8960) (#8972)
**Problem**
sbt always includes all transitive dependencies on the classpath.
This makes it easy to accidentally depend on transitive dependencies
without declaring them, leading to fragile builds that break when
a library changes its own dependencies.

**Solution**
Add a `dependencyMode` setting with three modes:

- DependencyMode.Transitive (default) — current behavior, all
  transitive dependencies on the classpath
- DependencyMode.Direct — only declared dependencies plus
  scala-library on the classpath
- DependencyMode.PlusOne — declared dependencies plus their
  immediate transitive dependencies plus scala-library

Fixes sbt/sbt#8942

Co-authored-by: Dream <42954461+eureka928@users.noreply.github.com>
2026-03-24 00:39:25 -04:00
Anatolii Kmetiuk 0529df8795 Allowlist-based approach to VCS string sanitization 2026-03-23 23:32:54 -04:00
Anatolii Kmetiuk e32e2455c9 Harden Windows VCS URI fragments against command injection
- Use Process(argv) for git/hg/svn without cmd /c on Windows
- Add VcsUriFragment.validate for fragments in clone/checkout/update
- Add tests
2026-03-23 23:32:37 -04:00
BitToby ce638e7a0f 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-22 23:57:15 -04:00
eugene yokota ef9c5bfc9c
[2.0.x] Add VF keys (#8963)
**Problem**
java.io.File cannot participate in cached task.

**Solution**
This adds a few VF-equivalent keys so they can participate
in cached task.
2026-03-22 23:35:22 -04:00
eugene yokota 023d3ba2c5
[2.0.x] Hide projectDescriptors (#8959)
**Problem**
projectDescriptors key depends on Ivy, and will be removed.

**Solution**
This hides the key in 2.0.x branch.
2026-03-22 02:15:37 -04:00
eugene yokota b4ee7ffc52
[2.x] fix: Undefined per-project settings order (#8953)
Closes #7173

Co-authored-by: Daniil Sivak <seroperson@gmail.com>
2026-03-21 15:49:19 -04:00
eugene yokota 2d375097e4
[2.x] Update semanticdbVersion in SemanticdbPlugin.scala (#8908)
Co-authored-by: kenji yoshida <6b656e6a69@gmail.com>
2026-03-15 05:53:11 -04:00
eugene yokota 009997f4e0
[2.x] Tweak the prompt (#8876) (#8877)
**Problem/Solution**
Tweak the shell prompt to differentiate sbt 1.x vs 2.x.
2026-03-06 00:29:04 -05:00
eugene yokota 660e8f92df
[2.x] fix: IgnoreSourceChanges now works (#8820) (#8853)
Closes #6773

Co-authored-by: Daniil Sivak <seroperson@gmail.com>
2026-03-01 05:29:06 -05:00
eugene yokota bf33f51d10
[2.x] feat: Add allowMismatchScala setting (#8804) (#8849)
sbt 2.x allows `dependsOn(...)` between subprojects with mismatched
Scala versions without any warning or error. This can lead to confusing
classpath issues at compile or runtime, especially now that Scala 3.8+
has dropped backward TASTy compatibility with 2.13.

Per review feedback, move the Scala version mismatch check from
compileTask to projectDependenciesTask, where PR #8681 already handles
Scala version mixing logic. This provides earlier detection and keeps
the validation co-located with cross-version resolution.

Generated-by: Copilot

Co-authored-by: dev-miro26 <121471669+dev-miro26@users.noreply.github.com>
2026-03-01 05:27:40 -05:00