Commit Graph

3897 Commits

Author SHA1 Message Date
BitToby f81a1524bb
[2.x] fix: Stabilize progress indicator sort (#8984)
When multiple tasks run in parallel, the super shell progress lines reorder in a semi-random manner on every refresh because they are sorted by raw elapsed microseconds. Tasks that start at nearly the same time constantly swap positions due to sub-second timing jitter, making the display hard to read.

This fixes the sort key to use elapsed seconds (rounded down) with task name as a tiebreaker, matching the granularity already shown to the user (e.g. 3s). Tasks displaying the same elapsed second now stay alphabetically stable instead of flickering.
2026-03-26 18:17:30 -04:00
BitToby 99471da5f1
[2.x] fix: Fix ProjectMatrix base directory resolution for source dependencies (#8983)
**Problem**

ProjectMatrix.baseSettings computes sourceDirectory and unmanagedBase using base.getAbsoluteFile, which resolves relative paths against the JVM's working directory. This works fine within a single build, but breaks for source dependencies - when an external build loaded via ProjectRef(file("ext/lib"), "lib") uses projectMatrix.in(file(".")), the file(".") resolves to the root project's directory instead of ext/lib/.

As a result, the matrix project picks up wrong sources and compilation fails.

**Solution**
Replace base.getAbsoluteFile with IO.resolve((ThisBuild / baseDirectory).value, base). Since ThisBuild / baseDirectory is set per build unit during loading, this correctly resolves against each build's own root directory.

sourceDirectory and unmanagedBase now derive from the resolved projectMatrixBaseDirectory setting.
2026-03-25 22:41:56 -04:00
BrianHotopp b362a0ba91
[2.x] fix: Emit <type> in POM for non-jar explicit artifacts (#8975)
PomGenerator never emitted <type> for dependencies with explicit
artifacts, so a WAR dependency would appear in the POM without
<type>war</type>. Maven then treats it as a JAR dependency, resolving
the wrong artifact.

Uses the primary (non-classifier) artifact to determine the type,
so .withSources()/.withJavadoc() classifier artifacts don't produce
spurious <type>doc</type> or <type>src</type> elements.

Fixes #1979

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 23:51:01 -04:00
Anatolii Kmetiuk 81d379f12d
[2.x] Fix Resolvers test formatting (#8968) 2026-03-23 21:47:42 -04:00
Anatolii Kmetiuk a9347cf220
Merge commit from fork
* 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

* Allowlist-based approach to VCS string sanitization
2026-03-23 20:12:58 -04:00
Dream 8132a392c3
[2.x] feat: Add dependencyMode setting to control classpath transitivity (#8960)
**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
2026-03-23 16:30:16 -04: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
kenji yoshida 6dcb601f73
Add scalafmt newlines.topLevelStatementBlankLines setting (#8949) 2026-03-21 02:58:49 -04:00
xuwei-k 5a74ba3992 Remove return statement in CommandExchange.scala 2026-03-20 15:04:42 +09: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
kenji yoshida b8ab0031f1
[2.x] refactor: Remove unnecessary unchecked annotation (#8926) 2026-03-19 20:11:01 -04:00
kenji yoshida 0608a660da
[2.x] refactor: Reduce return statements (#8925) 2026-03-19 20:09:31 -04:00
kenji yoshida 14606c593d
[2.x] ci: Add scalafix DisableSyntax.noReturns (#8922) 2026-03-19 10:48:10 -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 7fc522da65 Refactor: extract reportScalaLibEviction for Scala 2.13 and 3 eviction messages 2026-03-16 17:07:31 +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
bitloi e12b3c9b9a
[2.x] fix: Fixes script mode using Scala 3.x (#8900)
**Problem**
Scripts with scalaVersion 3.x in /*** */ and a shebang fail: -Xscript is
ignored by Scala 3, and the shebang line causes "Expected a toplevel
definition".

**Solution**
- Strip shebang when copying the script so the compiler never sees it.
- For Scala 3 only: do not add -Xscript; generate Main.scala wrapping the
  script body in object Main { def main(...) = { ... } }; use it as the
  single source and set run/mainClass to Main.
- For Scala 2: keep existing behavior (shebang stripped, -Xscript + script
  base name).
- Use Def.uncached and ScalaArtifacts.isScala3(scalaVersion.value) so
  embedded scalaVersion from /*** */ is respected.
2026-03-14 23:28:34 -04:00
seroperson 6dcce4cf2d
[2.x] fix: addressing review comments 2026-03-13 09:34:32 +03:00
seroperson c9fe1635f4
[2.x] feat: updating remote vcs projects
Closes #1284
2026-03-12 13:15:14 +03:00
Dream b3d2733fb1
[2.x] fix: Remove projectDescriptors key that leaks Ivy types (#8894)
**Problem**
The projectDescriptors key in sbt.Keys leaked Ivy classes
(ModuleRevisionId, ModuleDescriptor) through its API surface.
No external plugins use this key.

**Solution**
Remove projectDescriptors entirely. IvyDependencyPlugin now uses
its internal depMap method directly for projectResolverTask and
coursierExtraProjectsTask, eliminating unnecessary Any casts.
The descriptors field is also removed from GlobalPluginData.

Fixes sbt#8865
2026-03-11 14:53:39 -04:00
kenji yoshida d6e6d28f87
Delete checkPluginCross task. Add sourceGenerators for PluginCross (#8897) 2026-03-11 14:40:49 -04:00
kenji yoshida 5fb9f3c5fa
[2.x] refactor: Use InputStream.transferTo (#8896)
https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/InputStream.html#transferTo(java.io.OutputStream)
2026-03-11 14:32:40 -04: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
kenji yoshida 963e38256c
[2.x] ci: Update java file formatter plugin (#8892) 2026-03-10 11:19:48 -04:00
kenji yoshida 02c403b7cf
Update semanticdbVersion in SemanticdbPlugin.scala (#8885) 2026-03-09 15:39:13 -04:00
kenji yoshida 1926a693da
Update TemplateCommandUtil.scala (#8884) 2026-03-09 14:27:01 -04:00
oolokioo7 e15df63cac
[2.x] fix: sbt-with-loglevel-error (#8883)
**Fix**
Wrap BuiltinCommands.setParser with Act.requireSession(...).
This makes the parser fail gracefully when no session is available, matching the behavior of other session-dependent parsers.
2026-03-08 17:04:37 -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
eugene yokota 8a77f7fb03
[2.x] Tweak the prompt (#8876)
**Problem/Solution**
Tweak the shell prompt to differentiate sbt 1.x vs 2.x.
2026-03-05 23:55:04 -05:00
eugene yokota 647dbc47f4
[2.x] Move compiler bridge to Update (#8836)
**Problem**
We want to grab tooling artifacts in update.

**Solution**
This adds binary compiler bridge artifacts into the update graph.
2026-03-04 02:35:38 -05:00
Dream 3579dd0a9f
[2.x] fix: Respect global log level in continuous build watcher (#8864)
**Problem**
Running `sbt -error ~run` still prints [info] messages from the watcher
("Monitoring source files...", "Build triggered by...", etc). The watcher
creates its logger using only the watchLogLevel setting (default Info),
ignoring the global log level set via CLI flags like -error or -warn.

**Solution**
In Continuous.getCallbacks, take the more restrictive of the watchLogLevel
and the global log level from State when configuring the watcher appender.

Fixes #7355
2026-03-04 02:35:18 -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
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
Dream c3e72f79c0
[2.x] fix: Backtick-quote project IDs in classloader error messages (#8830)
When a test fails with ClassNotFoundException/IllegalAccessError, sbt
suggests a set command to change classLoaderLayeringStrategy. If the
project name contains hyphens (e.g. bug-report), the suggested command
was syntactically invalid because it parses as subtraction in Scala.

Quote project IDs using Util.quoteIfNotScalaId so the suggested
commands are valid when copy-pasted.

Fixes #5803
2026-02-28 01:52:55 -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
bitloi 33ac10c1ce
[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-02-26 13:50:31 -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
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
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
kenji yoshida 62e43711f2
[2.x] refactor: Remove redundant conversions (#8786) 2026-02-22 23:44:17 -05:00