Commit Graph

17794 Commits

Author SHA1 Message Date
kenji yoshida fe1caa8ddf
Use enum instead of scala.Enumeration in sbt.Execute.State (#8788) 2026-02-22 22:21:29 -05:00
kenji yoshida 8c23c5ea60
Use foreachEntry instead of foreach if Map (#8787) 2026-02-22 22:21:08 -05:00
kenji yoshida 611cea8fbd
Add tailrec annotations (#8785) 2026-02-22 22:20:46 -05:00
kenji yoshida b7b3947b81
[2.x] refactor: Remove unnecessary nowarn annotation (#8784) 2026-02-22 19:25:45 -05:00
kenji yoshida 17ca2b3931
Fix raw types in java file (#8782) 2026-02-22 14:32:52 -05:00
kenji yoshida c1ada47c29
Fix warnings. Avoid copyArrayToImmutableIndexedSeq (#8781) 2026-02-22 06:04:21 -05:00
eugene yokota b1bfb6e627
[2.x] Fallback to HOME/.config/sbt (#8780)
**Problem/Solution**
When XDG_CONFIG_HOME is not defined, we should fallback to HOME/.config/sbt.
2026-02-22 00:02:30 -05:00
bitloi 861fbccaea
[2.x] fix: Fixes autoScalaLibrary in test classloader (#8776)
When Test / autoScalaLibrary := false, build the non-fork test classloader
without the ScalaInstance layer: use Flat strategy and project classpath
only (rawCP), so tests do not see sbt's scala-library and avoid
NoSuchMethodError / version mismatch (e.g. scala/scala build).

- ClassLoaders.testTask: read autoScalaLibrary; when false use Flat and
  rawCP-only fullCP, and do not add si.libraryJars to exclude.
- Add scripted test tests/autoScalaLibrary-test-loader that runs test
  with Test / autoScalaLibrary := false.
2026-02-21 14:59:46 -05:00
it-education-md ae1066ed12
[2.x] fix: Prefer direct key selection for testFull at root (#8775)
**Problem**
`testFull` can select an aggregate-only key before a directly defined root key.
In issue #8772 this causes root project tests to be skipped, so a failing root test can pass unexpectedly.

**Solution**
Prefer directly defined keys in `Act.select`, and only fall back to aggregate-only candidates when no direct key exists.
Add scripted regression test `tests/i8772-root-project-testfull` and keep `project/extra-projects-key-aggregate` behavior intact.
2026-02-21 03:05:25 -05:00
Douglas Ma a7d5f45515
[2.x] fix: Reject java.io.File as cached task output type (#8766)
Change the behavior when a cached task's output type contains
java.io.File: instead of silently skipping the cache, throw a
compile-time error with a message recommending xsbti.VirtualFileRef,
xsbti.HashedVirtualFileRef, or xsbti.VirtualFile, and linking to the
caching documentation.

Internal sbt tasks that return File types are wrapped with
Def.uncached to opt out of caching.

Fixes https://github.com/sbt/sbt/issues/8762

Generated-by: GitHub Copilot (Claude)

* [2.x] fix: Reject java.io.File as cached task output type

Use @transient on File-returning keys in Keys.scala instead of
wrapping tasks with Def.uncached in Defaults.scala. This ensures
build users who rewire these tasks also get caching skipped
automatically.

- Add @transient to 19 File-returning taskKey definitions in Keys.scala
- Revert Def.uncached wrappers from Defaults.scala
- Error at compile time when File is used as cached task output type
- Update error message to recommend @transient and link to docs
- Update scripted tests to use @transient approach

Fixes #8762

Generated-by: GitHub Copilot (Claude Opus 4.6)
2026-02-21 01:35:46 -05:00
Rikito Taniguchi 4a5701cb8e
[2.x and 1.x] Respect `scalaOrganization` in compiler bridge resolution (#8732)
**Problem**
`scalaOrganization` was ignored during compiler bridge resolution because `ZincLmUtil.getDefaultBridgeModule` hard-coded `ScalaArtifacts.Organization` (`org.scala-lang`).

**Solution**
Add a `scalaOrganization` parameter to `ZincLmUtil` methods, and passing `scalaOrganization` value to those methods.

Generated-by: Claude Opus 4.6
2026-02-21 01:11:10 -05:00
bitloi c6f67d706f
[2.x] feat: XDG directory standard (#8769)
- Add SysProp.defaultGlobalBaseDirectory: uses SBT_CONFIG_HOME,
  XDG_CONFIG_HOME/sbt (Unix), LOCALAPPDATA/sbt (Windows), else ~/.sbt
- BuildPaths.defaultGlobalBase delegates to SysProp for consistent default
- sbt script: inject -Dsbt.global.base from XDG when not already set;
  getPreloaded() fallback uses SBT_CONFIG_HOME/XDG_CONFIG_HOME
- sbt.bat: use LOCALAPPDATA/sbt when --sbt-dir not set
- Tests: BuildPathsTest (property + absolute path), RunnerScriptTest (XDG)
2026-02-20 23:32:48 -05:00
NeedmeFordev 2f14fd8bb1
implemente using PrettyPrinter instead of CompactPrinter (#8773) 2026-02-20 22:39:41 -05:00
xuwei-k 167b5d04ba Update sbt plugins 2026-02-21 09:27:34 +09:00
Douglas Ma a00814a5c8
[2.x] fix: Resolve virtual file refs in scaladoc options (#8768)
When `semanticdbEnabled := true` is set on Scala 2.x projects, the
`doc` task fails because `${CSR_CACHE}` placeholders in scalacOptions
(specifically the `-Xplugin:` path for the semanticdb compiler plugin)
are not resolved before being passed to Scaladoc.

This fix resolves virtual file references (containing $) in
scalacOptions before passing them to the Scaladoc bridge, matching
what zinc's MixedAnalyzingCompiler already does for compilation
(see sbt/zinc#1545).

Fixes sbt/sbt#8740

Generated-by: GitHub Copilot (Claude Opus 4.6)
2026-02-20 15:31:46 -05:00
bitloi c045c72d6d
[2.x] feat: repositories_force support (#8761)
The launcher (1.6.0+) sets override from repository-override and passes it
via isOverrideRepositories(). No need to duplicate the file check in sbt.
2026-02-20 01:52:59 -05:00
bitloi b634e1b507
[2.x] fix: Relax non-delegation for settings on shell (#8751)
Allow settings to delegate when the user specifies an explicit scope
(config or task axis), so that e.g. Compile/console/fork resolves
when console/fork is defined in a delegated scope. Tasks continue to
not delegate (getDirect only) so non-existent scopes like Compile/update
still fail as in 2.0.0.
2026-02-17 20:06:53 -05:00
Lazz 02d9d4c699
[2.x] fix: Support inline comments in .jvmopts and .sbtopts files (#8758)
**Problem**
After PR #8730 (commit 921efce), inline comments in .jvmopts and .sbtopts files cause errors.
For example, `--add-opens=java.base/java.util=ALL-UNNAMED # comment` results in:
Error: Could not find or load main class #

The # and everything after it is now parsed as separate arguments instead of being stripped as a comment.

**Solution**
Update the sed command in outputConfigFileTokens() to strip inline comments (everything from # to end of line) before parsing tokens.

The new s/\s*\#.*// pattern matches optional whitespace + # + rest of line and removes it.

Generated-by: Claude Sonnet 4.5
2026-02-17 14:42:16 -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
kenji yoshida 7a3d669801
[2.x] ci: Update mima settings (#8753) 2026-02-17 13:32:25 -05:00
kenji yoshida d6ebe3cc69
[2.x] ci: Update onLoadMessage (#8754) 2026-02-17 13:30:04 -05:00
bitloi f870b60b7c
[2.x] feat: sbtw launcher (#8742)
- Add sbtwProj: Scala 3.x launcher with scopt, drop-in for sbt.bat
- Config: .sbtopts, .jvmopts, sbtconfig.txt, JAVA_OPTS/SBT_OPTS precedence
- Options: --client, --server, --jvm-client, mem, sbt-version, java-home, etc.
- sbt 2.x defaults to native client; --server forces JVM launcher
- JVM run via xsbt.boot.Boot; native via sbtn with --sbt-script
- build.sbt: sbtwProj in root build and allProjects; NativeImagePlugin
- Fixes: JAVA_OPTS then .jvmopts, build.properties trim, shutdownAll PID, Iterator.lastOption
2026-02-16 16:21:30 -05:00
eugene yokota 34206097cf
[2.x] Zinc 2.0.0-M14 (#8747) 2026-02-15 20:44:34 -05:00
eugene yokota 758b39faa3
[2.x] Bump semanticdbVersion (#8746) 2026-02-15 17:01:40 -05:00
eugene yokota f132dc0a67
Merge pull request #8744 from bitloi/fix/8741-dependency-lock-file-url
[2.x] fix: Fixes dependency lock file url
2026-02-15 16:52:23 -05:00
bitloi d7cb2c07a0
Merge branch 'develop' into fix/8741-dependency-lock-file-url 2026-02-15 06:10:12 -05:00
bitloi b53342da15 Fix ActionCache: treat invalid/empty JSON as cache miss
Catch parse errors when reading cached values and return Left(None)
so the task is re-run instead of failing with IncompleteParseException.
Fixes plugins/dotty-sandwich scripted test flake.
2026-02-15 07:50:38 +01:00
bitloi 7759a07454 chore: empty commit to re-run CI 2026-02-15 07:47:16 +01:00
eugene yokota eaa1c0845d
[2.x] fix: Fixes sbt 2.x pluing resolution (#8743)
**Problem**
Adopting Scala 3.8 on sbt 2.x has created confusing errors with scala-library mismatch,
popping up as undefined summon.

**Solution**
Removing the Provided scope seems to work.
2026-02-15 01:30:52 -05:00
bitloi ef6968e20c Path normalization for Windows + scalafmt
- CacheUrlConversion: normalize paths for comparison (forward slashes)
  and strip leading slash on Windows file URIs so cache matching works.
- Apply scalafmt to touched files.
2026-02-15 05:21:54 +01:00
bitloi afae6daea2 Fix #8741: dependencyLock no longer captures file:// URLs
- Add CacheUrlConversion in lm-coursier internal to convert cache file
  paths back to original repository URLs (single place for logic).
- CoursierDependencyResolution delegates to CacheUrlConversion.
- DependencyLockManager.createFromUpdateReport now accepts optional
  cacheDir; when an artifact has a file URL it either converts via
  cache dir (Coursier layout) or fails with a clear message.
- dependencyLock task passes csrCacheDirectory so lock file gets
  portable HTTPS URLs instead of machine-specific cache paths.

Expectation 1: Lock file contains original Maven Central (or repo) URLs.
Expectation 2: If conversion is not possible, lock creation fails.
2026-02-15 05:12:34 +01:00
bitloi 14211d7c4f
[2.x] fix: Note that dynamic usage isn't going to be linted (#8725)
Document lintUnused limitation for .all(ScopeFilter).value per review; revert dynamic-deps implementation
2026-02-14 21:20:56 -05:00
PandaMan 921efce541
[2.x] fix: Handle JVM parameters with spaces in dot files (#8730)
**Problem**

The sbt launcher script used naive word splitting when parsing `.sbtopts` and `.jvmopts`, so arguments with spaces were split incorrectly. For example, `-J--add-modules jdk.incubator.concurrent` in `.sbtopts` and `-Dtest.key="value with spaces"` in `.jvmopts` were not passed to the JVM as intended.
2026-02-14 03:17:44 -05:00
eugene yokota 38b48396b6
[2.x] Print warning about scala-reflect not found (#8733)
**Problem**
scala-reflect not found issue is confusing.

**Solution**
Print out a specialized warning message.
2026-02-14 03:02:28 -05:00
PandaMan c7da2b72c3
[2.x] fix: Fixes explicitlySpecified and selectors for testOnly (#8727)
**Problem**
When the user runs testOnly with an explicit suite name (e.g. testOnly com.example.MySuite),
ScalaTest suites annotated with @DoNotDiscover were not run because sbt always passed
explicitlySpecified=false to the test framework.

**Solution**
In Tests.processOptions, when the user has specified test filters (orderedFilters.nonEmpty),
mark the filtered tests as explicitlySpecified=true with SuiteSelector so frameworks
can run @DoNotDiscover suites when explicitly requested.
2026-02-13 09:19:05 -08:00
azdrojowa123 9ca4f186f1
[2.x] fix: Fixes the local artifact handling in updateSbtClassifiers task (#8734)
- this should also work for global plugins once they are fixed in sbt 2.x
- add `missingOk` support in classifier resolution to enable failure-tolerant artifact retrieval
2026-02-13 09:15:36 -08:00
Pluto 0cae58403f
[2.x] fix: handle --version in sbt 2.x project dirs (sbt#8717) (#8735)
**Problem**
`sbt --version` in sbt 2.x project directories was delegated to the native client, which could try to start/connect to a server instead of printing version info.

**Solution**
Skip native-client delegation when `--version` is requested, and add runner-script tests for sbt 1.x and 2.x project variants.
2026-02-13 09:10:51 -08:00
PandaMan 6d94d6db61
[2.x] fix: lastGrep ignores ANSI escape sequences when matching (#8726)
**Problem**
When `last` output includes ANSI escape sequences (e.g. colored `[error]` lines), `lastGrep <pattern>` was matching against the raw string. The pattern could fail to match because it was compared to text like `\u001B[31merror\u001B[0m` instead of `error`, or matching was inconsistent.

**Solution**
- Strip ANSI from each line before running the regex, using `EscHelpers.stripColorsAndMoves` from `sbt.internal.util`.
- **`Output.lastGrep`** (keys and file overloads): lines from the last run are stripped, then the pattern is applied to the stripped text; matching and printed lines are based on visible text.
- **`Output.grep`**: each line is stripped before `showMatches(pattern)` so the pattern is applied only to visible content.
2026-02-09 21:13:46 -08: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
PandaMan 20ce3abe5f
[2.x] fix: Fixes testing EventHandler race condition
**Problem**
ScalaTest's `AsyncFunSuite` invokes the test framework's event handler **asynchronously**. sbt's `TestFramework` was collecting events in a **`ListBuffer`**, which is not thread-safe. With multiple suites (e.g. `IgnoreBugTestA` and `IgnoreBugTestB`), concurrent `handle()` calls could corrupt the buffer, so events from the second suite were lost or merged incorrectly and the summary showed wrong suite/test counts.

**Solution**
Replaced the event buffer in `sbt.TestFramework`'s `EventHandler` with a **thread-safe** collection: **`CopyOnWriteArrayList`** (from `java.util.concurrent`). Event handling now uses:
- `CopyOnWriteArrayList[Event]` for `results`
- `results.add(e)` in the handler
- `results.asScala.toList` when building `TestEvent` / `SuiteResult` (via `scala.jdk.CollectionConverters._`)

This preserves ordering and ensures all suites' events are reported correctly when using async styles like `AsyncFunSuite` with `test`/`ignore`.
2026-02-09 10:55:06 -05:00
PandaMan b2fea15030
[2.x] fix: Handle CancellationException gracefully with usePipelining (#8718)
When usePipelining is enabled and compilation has errors, CancellationException
was being thrown and showing confusing stack traces to users. This fix catches
the exception in ConcurrentRestrictions.take() and converts it to Incomplete,
which is properly handled by the task execution framework without showing stack
traces.

- Added CancellationException import
- Wrapped jservice.take().get() in try-catch
- Convert CancellationException to Incomplete to prevent stack traces
- Added scripted test to verify the fix

Fixes #7973
2026-02-09 02:28:54 -05:00
PandaMan f47afb5b49
[2.x] fix: Fixes evicted warning for version intervals (#8719)
When a dependency declares a version range (e.g. Ivy [1.3.1,2.3] or comma-separated "1.3.1,2.3" as used by Coursier), and the resolver picks a version inside that range, sbt was still reporting an eviction warning. The chosen version satisfies the range, so it should not be reported as an eviction.

Example (from #6244): oauth2-oidc-sdk and nimbus-jose-jwt both depend on net.minidev:json-smart with range [1.3.1,2.3]. Resolution selects 2.3, which is within the range. Before this fix, sbt reported an eviction for json-smart even though 2.3 satisfies [1.3.1,2.3].
2026-02-09 02:27:28 -05:00
eugene yokota 3e3cde19b9
[2.x] fix: Disk cache label (#8716)
**Problem**
Currently symlink hit is reported separately from the disk cache,
which is not necessary.

**Solution**
Rename the symlink label to disk.
2026-02-07 23:40:16 -05:00
PandaMan de2c27abeb
[2.x] fix: handle --script-version sbt 2.x project dirs (#8715)
When in an sbt 2.x project directory, the script used to delegate to sbtn
before checking --script-version, so 'sbt --script-version' ran sbtn and
failed. Now we print the script version and exit before the native client
branch.
2026-02-07 22:16:21 -05:00
bitloi f6319f19a3
[2.x] fix: Fixes ThisBuild-scoped keys using root project's aggregates (#8703)
Build-level references (ThisBuild, BuildRef) should not participate
in aggregation. Only project-level references should aggregate.

Previously, when querying `ThisBuild/version`, the aggregation logic
would resolve ThisBuild to a BuildRef, then convert it to the root
project's ProjectRef, causing it to incorrectly use the root project's
aggregate definitions.

The fix uses pattern matching to distinguish BuildReference from other
reference types, returning None (no aggregation) for build-level scopes.

Fixes sbt/sbt#5349
2026-02-07 19:25:55 -05:00
eugene yokota 499ec520a7
[2.x] require coreutils for RPM (#8712)
**Problem**
Apparently sbt can fail when it doesn't have rm,
which can happen "when building relocatable RPM's and building an OS image in a chroot."

**Solution**
It was suggested that we require coreutils.
2026-02-07 17:23:39 -05:00
PandaMan 95c6d42f8e
[2.x] fix : BSP compile returns StatusCode.Error on failure (#8104) (#8709)
- BuildServerProtocol: for Result.Inc(cause), return StatusCode.Error for any
  non-InterruptedException (was throwing for non-CompileFailed, causing JSON-RPC
  error instead of BspCompileResult with statusCode Error)
- BuildServerTest: add test 'buildTarget/compile - returns StatusCode.Error
  when compilation fails' (introduce compile error, compile via BSP, assert
  statusCode == Error)
2026-02-07 11:01:49 -05:00
PandaMan f6f00c1931
[2.x] fix: Exclude autoStartServer from lintUnused warnings (#6624) (#8708)
**Problem**
Setting `Global / autoStartServer := false` in global.sbt triggers a
spurious lintUnused warning, even though the setting is correctly used
by sbt's server startup logic.

**Solution**
Add `autoStartServer` to the `excludeLintKeys` set in LintUnused.scala,
similar to other server-related settings like `serverConnectionType` and
`serverIdleTimeout`. This prevents the warning while maintaining the
functionality of the setting.
2026-02-07 10:47:25 -05:00
eugene yokota 4681dc714c
Merge pull request #8705 from eed3si9n/wip/console-task-follow-up
[2.x] client-side console and fixes
2026-02-07 01:07:58 -05:00
Eugene Yokota 138621eacb [2.x] client-side console and fixes
**Problem**
1. forked console is missing user code from the classpath.
2. forked console still blocks the server.

**Solution**
1. This includes proper products and classpaths to the console.
2. This also implements client-side run for console.
2026-02-07 00:42:54 -05:00