Commit Graph

3864 Commits

Author SHA1 Message Date
eureka928 1c4094e35d [2.x] refactor: Fix ivyless publish fallbacks and add ivyless publishM2
**Problem**
1. The ivyless publish task had ivyModule.value and publisher.value calls
   inside match/case fallback branches. sbt's macro hoists ALL .value calls
   from ALL match branches as task dependencies regardless of runtime path,
   causing failures when useIvy=false even for supported repo types.
2. publishM2 used publishOrSkip which errors when useIvy=false, but M2
   targets MavenCache which the ivyless path already supports.

**Solution**
1. Remove hoisted .value calls from fallback branches in ivylessPublishTask.
   Replace with direct sys.error calls since these branches handle truly
   unsupported repo types.
2. Add ivylessPublishM2Task using Def.ifS that publishes to MavenCache
   via ivylessPublishMavenToFile when useIvy=false.

Generated-by: Claude claude-opus-4-6
2026-03-03 13:36:10 +01:00
eureka928 e7882b9cd0 [2.x] refactor: Gate Ivy-specific tasks behind useIvy
**Problem**
Several tasks (makePom, makeMavenPomOfSbtPlugin, deliverTask, publisher,
publishOrSkip, depMap, GlobalPlugin dependency mapping) unconditionally
depend on Ivy infrastructure, preventing ivyless operation.

**Solution**
Add useIvy guards to each task:
- makePom and makeMavenPomOfSbtPlugin: error when useIvy=false
- deliverTask: error when useIvy=false
- publisher: error when useIvy=false
- publishOrSkip: error when useIvy=false
- depMap: return empty map when useIvy=false
- GlobalPlugin.extract: skip ivyModule.dependencyMapping when useIvy=false

Generated-by: Claude claude-opus-4-6
2026-03-03 13:36:10 +01:00
eureka928 8746f5b291 [2.x] refactor: Replace ivyModule with Coursier descriptor in evicted task
**Problem**
The evicted task directly uses ivyModule.value to get a module descriptor.
This creates an unnecessary dependency on Ivy for eviction warnings.

**Solution**
Use dependencyResolution.value.moduleDescriptor() which works with both
Ivy and Coursier resolvers, removing the direct Ivy coupling from the
eviction checking path.

Generated-by: Claude claude-opus-4-6
2026-03-03 13:36:10 +01: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
bitloi 20f4a9c3b2
[2.x] fix: Fixes java++ tab completion (#8778)
Fixes #4310

Per review, the OOM comes from the version parser - token(StringBasic)
on the right side of || has no examples constraint. Move
.examples(knownVersions*) from the inner number parser to wrap the
entire || expression, so both alternatives are bounded.
2026-02-22 23:43:38 -05:00
kenji yoshida c3a00771b3
[2.x] refactor: Use minBy instead of sortBy and head (#8792) 2026-02-22 22:23:15 -05:00
kenji yoshida 4dd0a9c89c
Use collectFirst instead of collect and headOption (#8789) 2026-02-22 22:22:38 -05:00
kenji yoshida 808dfefa59
[2.x] refactor: Fix Aggregation.printSettings pattern matching (#8790) 2026-02-22 22:21:50 -05:00
kenji yoshida 8c23c5ea60
Use foreachEntry instead of foreach if Map (#8787) 2026-02-22 22:21:08 -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
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
bitloi d7cb2c07a0
Merge branch 'develop' into fix/8741-dependency-lock-file-url 2026-02-15 06:10:12 -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
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
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
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
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
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 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
Eugene Yokota f6799830c7 Move consoleTask 2026-02-06 23:56:30 -05:00
calm 772f616a29
[2.x] fix: Restore Scala 2 artifact version unification (#8689) (#8700)
Commit 92b0564dc (fix for #8632) changed `csrSameVersions` so that Scala 2.13+ only aligned `scala-library` and `scala3-library`. This removed `scala-compiler` and `scala-reflect` from version
unification, so transitive dependencies pulling in an older `scala-compiler` (e.g. 2.13.15 via `refined_2.13`) were no longer evicted to match `scalaVersion` (e.g. 2.13.18).
2026-02-06 19:55:41 -05:00
bitloi 4e0180d759
[2.x] fix: Use correct configuration identifier for display (#8698)
**Problem**
The configuration name translation in logging was incorrect. When a
configuration like MultiJvm (id="MultiJvm", name="multi-jvm") was
displayed, it showed "Multi-jvm" instead of "MultiJvm" because the
display logic was guessing the identifier by capitalizing the ivy
config name.

**Solution**
This fix:
- Adds configNameToIdent reverse mapping in ConfigIndex to look up
  the correct Configuration.id from the ivy config name
- Adds toConfigIdent method in KeyIndex trait for display lookup
- Updates Scope.display to accept a config name lookup function
- Updates showLoadingKey and showContextKey to use the index lookup

Fixes #5211

Generated-by: Claude
2026-02-06 12:54:58 -05:00
calm 47e7133260
[2.x] feat: drop other idle servers on client exit (#8610) (#8701)
Implements cooperative idle server cleanup for `sbtn` (issue #8610). When a client disconnects from an sbt server, that server notifies all
other registered servers to shut down if they've been idle long enough and have no connected clients. This prevents accumulation of idle
background JVMs across projects.

fixes #8610
2026-02-06 12:52:36 -05:00