Commit Graph

448 Commits

Author SHA1 Message Date
kenji yoshida f92c06155c
Delete sbt-test/lm-coursier/neo-sbt-scalafmt (#8931) 2026-03-19 20:41:45 -04:00
kenji yoshida b839d308e1
[2.x] refactor: Use new Array instead of Array.fill (#8929) 2026-03-19 20:18:47 -04:00
BitToby 963acca8ad
[2.x] fix: Preserve user-specified scope axes in command instead of silently discarding them (#8916)
**Problem**
set every silently discards scope axes the user provides. Running:

set every Test / sources := Nil

empties sources in **all** scopes including Compile, not just Test. This happens because rescope in SettingCompletions.setAll strips the scope and forces Global.

**Solution**
Changed rescope to keep the user's config/task/extra axes and only wildcard the project axis. When no scope is given, behavior is unchanged - all axes match everything as before.
2026-03-18 00:53:54 -04:00
Anatolii Kmetiuk e6a2b536bf
Merge pull request #8915 from eed3si9n/wip/virtual-file
[2.x] Add VF keys
2026-03-18 11:37:56 +09:00
Eugene Yokota 5a767e3442 [2.x] Add VF keys
**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-17 02:33:13 -04:00
bitloi 7ad38eb221 [2.x] fix: Eviction error for downgrade of Scala 3.x (#6694)
**Problem**
When scalaVersion is Scala 3.x and a dependency brings a newer
scala3-library_3, sbt did not report an eviction error or warning.
The compiler could be older than the standard library on the
classpath, breaking compile-time alignment (e.g. scala/scala3#25406).

**Solution**
- In Compiler.scala, add an else if ScalaArtifacts.isScala3(sv) branch
  in scalaInstanceConfigFromUpdate that finds scala3-library_* on the
  Compile report and, if scalaVersion < that revision, fails (or warns
  when allowUnsafeScalaLibUpgrade := true) with the same pattern as
  the existing Scala 2.13 check (PR 7480). Message uses compile-time
  alignment wording and "See evicted to know why ... was upgraded from".
- Set allowUnsafeScalaLibUpgrade := true on b3 in stdlib-unfreeze so
  existing b3/run and b3/checkScala still pass.
- Add scripted tests: stdlib-unfreeze-scala3-eviction (expect compile
  to fail) and stdlib-unfreeze-scala3-warn (expect success with warning).

Closes #6694
2026-03-16 01:45:33 +01:00
bitloi f4eff2da77 [2.x] fix: Eviction error for downgrade of Scala 3.x (#6694)
**Problem**
When scalaVersion is Scala 3.x and a dependency brings a newer
scala3-library_3, sbt did not report an eviction error or warning.
The compiler could be older than the standard library on the
classpath, breaking compile-time alignment (e.g. scala/scala3#25406).

**Solution**
- In Compiler.scala, add an else if ScalaArtifacts.isScala3(sv) branch
  in scalaInstanceConfigFromUpdate that finds scala3-library_* on the
  Compile report and, if scalaVersion < that revision, fails (or warns
  when allowUnsafeScalaLibUpgrade := true) with the same pattern as
  the existing Scala 2.13 check (PR 7480). Message uses compile-time
  alignment wording and "See evicted to know why ... was upgraded from".
- Set allowUnsafeScalaLibUpgrade := true on b3 in stdlib-unfreeze so
  existing b3/run and b3/checkScala still pass.
- Add scripted tests: stdlib-unfreeze-scala3-eviction (expect compile
  to fail) and stdlib-unfreeze-scala3-warn (expect success with warning).

Closes #6694
2026-03-16 00:15:43 +01:00
eugene yokota 39fa98ef79
[2.x] Update to Coursier 2.1.25-M24 (#8381)
This forward ports (https://github.com/coursier/sbt-coursier/pull/570), and follows along some of the migrated methods to work through the deprecations.
2026-03-13 22:57:38 -04:00
atoz96 b268321412
[2.x] test: Add nested-testquick scripted test (#8901)
**Problem**
The tests/nested-testquick scripted test only verified test and testQuick but did not exercise testOnly against individual test
classes, nor did it verify that a failing nested test class is detected.

**Solution**
- Added GoodCalcTest.java (with a Nested inner class) as a passing test.
- Added changed/BadCalcTest.java (with a Nested`inner class) as a deliberately failing test.
2026-03-13 21:05:43 -04:00
seroperson 6dcce4cf2d
[2.x] fix: addressing review comments 2026-03-13 09:34:32 +03:00
seroperson d322b2428c
[2.x] fix: remove staging directory before running tests 2026-03-12 13:17:43 +03:00
seroperson c9fe1635f4
[2.x] feat: updating remote vcs projects
Closes #1284
2026-03-12 13:15:14 +03:00
BinaryWorldTl 6821167032
[2.x] fix: Handle scala/toolkit.local when passed as argument to sbt new (#8887)
Running sbt new scala/toolkit.local with the template slug on the command line throws:

The same templates work when chosen from the interactive menu (sbt new with no args). The code path for “arguments provided” only consulted external template resolvers (e.g. Giter8), which do not handle these built-in local templates.
2026-03-10 23:46:51 -04:00
Dream d71fe5b7a3
[2.x] refactor: Extract lm-ivy to separate sbt-ivy plugin module (#8873)
Step 5 of #7640 — removes the compile-time dependency on lm-ivy from main/ by creating a standalone sbt-ivy plugin module.

- Create new sbt-ivy/ subproject with IvyDependencyPlugin AutoPlugin that provides all Ivy-specific functionality (ivySbt, ivyModule, ivyConfiguration, publisher, projectDescriptors, deliver/makeIvyXml)
- Move IvyXml.scala from main/ to sbt-ivy/
2026-03-10 23:30:06 -04:00
oolokioo7 b3d6c06731
[2.x] dependencyTree: add `--append` for file output in multi-module builds (#8878)
**Summary**
This adds an --append flag to the dependencyTree input task when used with --out. It allows running dependencyTree in multiple subprojects and appending their outputs to the same target file instead of overwriting.

**Solution**
- Add Arg.Append in the CLI parsing
- When --append is set, write using IO.write(..., append = true)
2026-03-06 14:53:18 -05:00
Dream ed96b4e1e0
[2.x] fix: Populate explicitArtifacts from classifier in UpdateReport (#8874)
**Problem**
When a dependency is declared with a classifier (e.g., classifier "linux-x86_64"),
the UpdateReport > ModuleReport.module.explicitArtifacts is empty. The classifier
data is available as Publication objects during Coursier resolution but is lost
when SbtUpdateReport reconstructs the ModuleID.

**Solution**
In SbtUpdateReport.moduleReport, extract explicit artifacts from Publications
with non-empty classifiers and apply them to the ModuleID used by ModuleReport.
This is done on a per-report copy to avoid mutating the shared moduleId cache.

Fixes #5491
2026-03-04 16:22:48 -05:00
Dream cf9d3d5a7a
[2.x] refactor: Make Ivy keys lazy/optional and flip useIvy default to false (#8866)
- Replace `ivyModule` with Coursier's `dependencyResolution.moduleDescriptor` in the `evicted` task, removing a direct Ivy dependency from the eviction-checking path
- Gate Ivy-specific tasks (`makePom`, `makeMavenPomOfSbtPlugin`, `deliverTask`, `publisher`, `publishOrSkip`, `depMap`, `GlobalPlugin.extract`) behind `useIvy` so they error or return empty when `useIvy = false`
- Fix `.value` hoisting bug in `ivylessPublishTask` where `ivyModule.value` and `publisher.value` inside `match/case` fallback branches were macro-hoisted as task dependencies regardless of runtime path, breaking all ivyless publishes
- Add `ivylessPublishM2Task` so `publishM2` works with `useIvy = false` (publishes to `~/.m2` via `ivylessPublishMavenToFile`)
- Flip `useIvy` default from `true` to `false`
2026-03-03 23:16:28 -05:00
Daniil Sivak 81edea48bc
[2.x] fix: Undefined per-project settings order (#8862)
Closes #7173
2026-03-03 14:09:14 -05:00
Renzo b1db6ba44d
[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-03-02 23:49:10 -05:00
bitloi 09c4856409
[2.x] fix: Unresolved dependency error for Coursier (#8869)
Fixes unresolved dependency path reporting for Coursier (`ResolveException.failedPaths`) and adds a stable scripted regression.

This PR addresses 5168 by reconstructing unresolved dependency caller chains from the Coursier resolution graph and attaching them to `ResolveException.failedPaths`. That allows unresolved warnings to show the full path from the missing module up to the root project.

It also adds and stabilizes `lm-coursier/unresolved-path` scripted coverage by:
- using a local test Maven repo fixture (no flaky remote test dependency)
- checking update stream output via an sbt task (`checkLog`) instead of shell `grep`
- asserting the unresolved path includes missing module, transitive caller, and root project
2026-03-02 23:21:53 -05:00
Dream 0d01cc0b10
[2.x] refactor: Remove Ivy from update path and decouple lm-coursier from lm-ivy (#8832)
- **Remove `ivyModule` from `updateTask0`**: Replace `IvySbt#Module` with `moduleSettings` + `DependencyResolution.moduleDescriptor()`, eliminating the Ivy dependency in the update path.
- **Replace direct Ivy usage in `Load.scala` and `TemplateCommandUtil`**: Use Coursier's `DependencyResolution` API for plugin bootstrapping and template resolution instead of constructing `IvySbt` instances directly.
- **Break `lm-coursier`'s dependency on `lm-ivy`**: Remove `IvySbt#Module` pattern match from `CoursierDependencyResolution`, replace `IBiblioResolver` usage in `Resolvers` with reflection, and switch build dependencies from `lmIvy` to `lmCore`.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 17:46:15 -05:00
bitloi dfa5e31571
[2.x] fix: make ScopeFilter .all ordering deterministic and preserve project filter order (#8861)
Fixes nondeterministic ordering in `ScopeFilter`-backed `.all(...)` aggregation.

`SettingKeyAll.all` and `TaskKeyAll.all` previously iterated a `Set[Scope]` using `toSeq`, which made returned values order-dependent on hash iteration. This PR keeps `.all(...)` deterministic and preserves explicit project ordering when a filter provides it (for example, `inProjects(c, a, b)`).
2026-03-02 17:42:24 -05:00
kenji yoshida 75d9834dec
[2.x] test: Use new wildcard syntax in test build files (#8844) 2026-03-01 02:53:29 -05:00
kenji yoshida 870e526a00
Avoid private[this] in test build files (#8839) 2026-03-01 01:46:56 -05:00
Renzo 5271babfa5
[2.x] fix: support comma-separated imports in build.sbt (#8829)
Summary
- Fix `SbtParser.importsToLineRanges` to prepend `import` keyword when missing from Dotty's `Import` AST node source spans
- Add unit test for comma-separated import parsing
2026-02-28 19:12:38 -05:00
Daniil Sivak 33d86d0cd2
[2.x] fix: IgnoreSourceChanges now works (#8820)
Closes #6773
2026-02-27 22:28:02 -05:00
Dream 034834bd71
[2.x] feat: Support doc / skip := true (#8824) 2026-02-27 08:41:04 -05:00
kenji yoshida f04093bd9f
[2.x] Fix lazy val name handling in Eval (#8818) 2026-02-26 10:57:27 -05:00
bitloi 19ebaaafb6
[2.x] perf: lightweight UpdateReport cache persistence (#8815)
- Add UpdateReportCache case class wrapping UpdateReportLite with stats/stamps
- Implement toCache/fromCache for conversion between UpdateReport and cache
- Add readFrom/writeTo for CacheStore persistence with backward compatibility
- Add fromLiteFull to JsonUtil for full reconstruction from lite format
- Update LibraryManagement to use new persistence API
- Add benchmark comparing full vs lite deserialization
- Add unit tests for persistence correctness
- Add scripted test for cache round-trip verification
2026-02-25 22:36:07 -05:00
Daniil Sivak 12cbd877bc
[2.x] fix: excluding artifacts w/o scala version suffix (#7454) (#8756)
**Problem**

Excluding artifacts using `.exclude(org, name)` requires you to
explicitly set scala version in `name`.

**Solution**

- Deprecating `.exclude(org, name)` in favor of new
  `.exclude(OrganizationArtifactName)`
- Fixing `lmcoursier.FromSbt` ignores `excludeRule.crossVersion`
2026-02-25 15:06:16 -05:00
BrianHotopp 87414a8733
[2.x] fix: Fixes double quotes handling in fork mode (#8765)
When using the arguments file (`@argsfile`) mechanism for forked runs,
double quotes inside arguments were not escaped, causing the JVM's
argument file parser to strip them. For example, passing `{"a":1}` as
an argument would result in `{a:1}`.

Escape `"` as `\"` in `createArgumentsFile`, matching the existing
backslash escaping, so the JVM correctly round-trips quoted arguments.

Fixes sbt/sbt#7129

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 23:22:48 -05:00
Angel98518 c031bdd9b1
[2.x] Add project id to Zinc debug log (#8750)
- CompileDebugLogger wraps logger to prefix debug messages with [projectId]
- projectIdFromScope derives id from task scope (avoids HashWriter on ResolvedProject)
- Wire CompileDebugLogger into compileIncrementalTaskImpl and compileJavaTask
- Add CompileDebugLoggerSpec unit test and i408-debug-invalidation-prefix scripted test
2026-02-24 21:55:39 -05:00
dev-miro26 3ca9a388df
[2.x] feat: Add allowMismatchScala setting (#8804)
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
2026-02-24 21:52:44 -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
kenji yoshida f976330759
Scala 3.8.2 (#8805) 2026-02-24 00:29:44 -05:00
kenji yoshida af57abe1ce
[2.x] test: Avoid old varargs splice syntax in test (#8806) 2026-02-24 00:18:11 -05:00
kenji yoshida 2688f7153c
[2.x] test: Use new wildcard syntax in test (#8807) 2026-02-24 00:15:37 -05:00
it-education-md cb498de41d
[2.x] fix: Fixes plugin toggle precedence between disablePlugins and enablePlugins (#8794)
Treat explicit plugin toggles as last-call-wins for the same plugin.
This avoids contradictory include/exclude states when disablePlugins(X) is followed by
enablePlugins(X) (and vice versa), aligning behavior with normal override expectations.

Apply the same semantics to ProjectMatrix and add regression coverage:
- unit tests in main/src/test/scala/ProjectSpec.scala
- scripted test in sbt-app/src/sbt-test/project/i1926-disable-enable-plugin
2026-02-23 00:11:57 -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
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
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
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
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