Commit Graph

513 Commits

Author SHA1 Message Date
Anatolii Kmetiuk 36d5ce728f minimize test 2026-05-27 11:30:18 +09:00
Anatolii Kmetiuk 99b30b8899 Fix duplicate autoplugins packageBin mappings 2026-05-27 11:30:18 +09:00
BrianHotopp 5e4d2744a1
[2.x] fix: Make custom-scala-org scripted test hermetic (#9260)
The original fixture pinned
  scalaOrganization := "io.github.scala-wasm"
  scalaVersion := "3.8.3-RC1-wasm-bin-SNAPSHOT"
and ran compile. The wasm fork never published a release of
scala3-library_3 -- only a snapshot to Sonatype's central-snapshots
repo, which has ~90-day retention. #8732 merged 2026-02-21; the
snapshot was GC'd ~2026-05-22 and develop CI began failing
deterministically.

Fixes #9259.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 14:18:40 -04:00
BrianHotopp b71319a153
[2.x] fix: Apply dependencyMode filtering to internal project deps (#9250)
Fixes #9009.

dependencyMode := DependencyMode.PlusOne strips every internal
project dependency from the compile classpath, even direct ones --
LibA/compile fails with Not found: CoreClass despite
LibA.dependsOn(Core). Direct mode happens to work today, but only by
accident (filterByDirectDeps matches against allDependencies, which
includes projectDependencies -- the bug surface is one step removed).

Root cause: ClasspathImpl.filterByPlusOne resolves the
direct-dep key set from UpdateReport, which only contains externally
resolved (LM) modules. Internal project refs never appear there, so
resolvedDirectKeys is empty for internal entries; plusOneKeys is
likewise empty; the final filter strips every internal classpath
entry whose moduleIDStr identifies an internal project. Diagnosis on
the issue by eureka0928.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 23:20:56 -04:00
Anatolii Kmetiuk 03965281df
Improve deprecation UX for watchSources (#9247) 2026-05-20 09:44:51 +09:00
Anatolii Kmetiuk 696626e195
[2.x] fix: Add regression test (#9246) 2026-05-19 10:57:23 -04:00
BrianHotopp 3eeac9deae
[2.x] fix: Collapse duplicate subtrees in dependency tree rendering (#9226)
Fixes #6886.

dependencyTree, dependencyBrowseTree, and inspect tree re-explore
the same node once per incoming edge. In a DAG with N levels and M
children per node the rendered output is O(M^N) -- the OP needed
>16 GB heap, #7360 has a 6 GB heap dump, and Friendseeker's analysis
on the issue showed the exponential re-traversal directly.

Fix: track a visited set across the renderer's recursion. The first
time a node is encountered it is rendered in full; on subsequent
visits the entry collapses to a one-line +- <id> (*) (ASCII) or a
<id> (*) leaf (JSON), matching Maven's dependency:tree (*)
convention. Cycle detection (separate parents set, (cycle) marker)
is unchanged.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 19:15:47 -04:00
kenji yoshida f454c05fe1
[2.x] refactor: Use scala.util.Using.resource instead of try-finally (#9230) 2026-05-16 05:51:07 -04:00
eugene yokota 57495c28dc
[2.x] fix: Include test arg into hash (#9222)
**Problem**
test -- foo passes on MUnit, allowing failing tests to be validated.

**Solution**
Include test args into the cache input.
2026-05-16 04:12:33 -04:00
BrianHotopp 68dde13fdc
[2.x] feat: Print cross-project test failure recap at end of aggregated run (#9214)
Fixes #2998

When test is run at the prompt in a multi-project build,
sbt aggregates <proj>/test across subprojects. Each subproject's
TestResultLogger emits its own pass/fail summary inline, but the
aggregation layer never restated which projects failed. The final
"sbt.TestsFailedException" line surfaced no project names or failing
test classes, so on CI users had to scrollback-grep through thousands
of log lines to find what broke.

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 15:41:39 -04:00
kenji yoshida 56cdef09f7
[2.x] refactor: Use InputStream.transferTo (#9212) 2026-05-14 00:36:20 -04:00
xuwei-k 04d9f36414 Use Files.readString instead of readAllBytes 2026-05-13 21:21:18 +09:00
kenji yoshida 00bd61d411
Add definedTestNames test (#9210) 2026-05-11 20:01:59 -04:00
Eugene Yokota e69e23aae1 Remove tests that checks for the iteration 2026-05-11 05:10:07 -04:00
Eugene Yokota 566f888045 [2.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-11 04:29:28 -04:00
eugene yokota c491f035f8
[2.x] test: Port tests to use lm-coursier (#9205)
**Problem**
Some tests are failing.

**Solution**

* Port EvictionErrorSpec to lm-coursier
* Port EvictionWarningSpec to lm-coursier
* Port InclExclSpec to lm-coursier
* Port ZincComponentCompilerSpec to lm-coursier
* Apparently we still need lmIvy
2026-05-10 04:40:15 -04:00
kenji yoshida 76992ed3f6
[2.x] test: Enable run/fork-loader scripted test (#9199) 2026-05-08 01:00:08 -04:00
eugene yokota 59c007d6a4
[2.x] test: Add move-file test (#9197)
**Problem**
Moving files around seems to break compile task.
2026-05-07 11:23:22 -04:00
kenji yoshida 0638907349
[2.x] test: Enable actions/eval-is-safe-and-sound scripted test (#9192) 2026-05-06 20:29:06 -04:00
kenji yoshida f4ae966a22
[2.x] test: Enable project/source-plugins scripted test (#9191) 2026-05-06 16:02:40 -04:00
eugene yokota 4ec3a753e7
[2.x] fix: Fix build.sbt file loading in subdirs (#9165)
**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-02 21:17:55 -04:00
Matt Dziuban 5757955fc7
[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 14:04:10 -04:00
kenji yoshida 0af7c2f4a6
[2.x] test: Add more ClassLoaderLayeringStrategy.Raw test (#9163) 2026-05-01 00:33:09 -04:00
kenji yoshida 71a5ad6448
[2.x] test: Add javaagent test (#9164) 2026-05-01 00:29:16 -04:00
eugene yokota 4a02167fa4
[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-04-30 12:35:30 -04:00
kenji yoshida b3d16be556
[2.x] fix: Fix error with "-language:postfixOps" (#9151) 2026-04-29 13:21:26 -04:00
eugene yokota 4617a6ca05
[2.x] fix: Fixes compilerPlugin(...) to ignore platform (#9135)
**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 15:14:51 -04:00
Ali Rashid 9275bda052
[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-26 14:31:42 -04:00
Zainab Ali 3b1dbae74a
[2.x] Add Test configuration to evictionWarningOptions (#9102)
* 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.
2026-04-23 23:06:54 -04:00
eugene yokota b98c4f8984
[2.x] fix: Fixes managedScalaInstance false support (#9121)
**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 00:30:32 -04:00
Anatolii Kmetiuk 4ebacc6e05
[2.x] fix: Include platform suffix in Artifact.artifactName (#9118) 2026-04-21 22:58:34 -04:00
Matthias Kurz 083dba59d6 [2.x] add no-op addDependencyTreePlugin shim for migration (#9067)
(cherry picked from commit e515decfc5)
2026-04-18 15:37:57 +09:00
Dream 81b81ce6b0
[2.x] fix: Fix consoleProject for Scala 3 (#9073)
**Problem**
consoleProject does not work with Scala 3 because the compiler bridge
does not implement REPL binding injection (scala/scala3#5069).
The bindings currentState, extracted, and cpHelpers are never
injected into the REPL session, causing Not found errors.

**Solution**
Work around the missing binding support by storing the three runtime
objects in a static holder (ConsoleProjectBindings) before launching
the REPL, and generating val definitions via initialCommands that
read from the holder. The original bindings are still passed to
Console to preserve Scala 2 backward compatibility.

Pass -Xrepl-interrupt-instrumentation:local to the REPL when the
consoleProject scala instance is 3.8 or newer. In local mode the
instrumented loader skips re-defining classpath classes and falls
through to standard parent-first delegation, so REPL code sees the
same singleton sbt.* and scala.* classes as the surrounding sbt
process — while still keeping interrupt support for REPL-defined code,
preserving Ctrl+C on long-running expressions like
(Compile / compile).eval.

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 01:37:24 -04:00
Clayton ef90ca0540
[2.x] feat: Forward test events to listeners as they are emitted (#9087)
Test report listeners now receive testEvent callbacks as the underlying test framework emits events, instead of only after a whole group finishes. startGroup / endGroup timing is aligned with that streaming model for both in-process and forked test runs.

No public API changes - only listener callback timing and the internal worker <-> sbt JSON-RPC protocol.
2026-04-16 00:58:06 -04:00
kenji yoshida 9d620f3b1f
[2.x] refactor: Use Files.writeString instead of Files.write (#9093) 2026-04-15 22:29:19 -04:00
Jonathan Chang dd93c92ebc
[2.x] feat: Add English aliases cross and switch for + / ++ (#9051)
Fixes #3137. Adds discoverable English-name alternatives for the symbolic
cross-build commands using the | parser combinator, making them more
beginner-friendly without adding separate commands.
2026-04-14 23:03:48 -04:00
BitToby 05cd00e135
[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-12 18:24:30 -04:00
Dream 512d2d460c
[2.x] fix: Add description and url to PomGenerator output (#9069)
**Problem**
PomGenerator (introduced in #8873) was missing <description> and <url>
elements that the old Ivy-based MakePom included. Setting `description`
and `homepage` in build.sbt had no effect on the generated pom.xml.

**Solution**
Add makeDescription and makeHomePage helpers to PomGenerator, matching
the behavior of MakePom. Add test assertions for both fields.

Fixes #9054
2026-04-12 01:59:02 -04:00
kenji yoshida c47fc6bbd8
[2.x] fix: Delete src/main/resources/log4j2.xml (#9071) 2026-04-12 01:57:00 -04:00
kenji yoshida 78afa8fb96
[2.x] test: Fix warnings in scripted tests (#9062) 2026-04-11 03:07:52 -04:00
kenji yoshida 75dcd1229b
Enable project-matrix/native test (#9038) 2026-04-07 08:15:43 -04:00
eugene yokota 6c8ee6ea37
[2.x] Remove Path type from caching (#9032)
**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 14:40:33 -04:00
kenji yoshida 8ad6ada60f
[2.x] Scala 3.8.3 (#8997) 2026-04-05 14:28:47 -04:00
corevibe555 606bb3b59c
[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-04-05 13:47:36 -04:00
kenji yoshida 67e3b8b01b
[2.x] refactor: Remove unnecessary language.experimental.macros import (#9025) 2026-04-05 13:17:37 -04:00
eugene yokota 5ad9abac2f
[2.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 03:13:23 -04:00
BitCompass 1f2d14aa3e
[2.x] fix: derivedProjects not invoked when no explicit root project is defined (#9012)
**Problem**
When build.sbt contains no explicit project definition (e.g. just bare settings with no lazy val root = project.in(file("."))), sbt creates a synthetic root project. In Load.loadTransitive, this synthetic root was processed with expand = false, which prevented AutoPlugin.derivedProjects from being called.
Any plugin relying on derivedProjects to inject projects would fail with "Reference to undefined setting" errors.

The workaround was to add an explicit root project in build.sbt (val root = project.in(file("."))), which caused the Some(root) branch to execute with expand = true.

**Solution**

Removed the expand variable from loadTransitive and pass true directly to processProject. Previously, the Some(root) branch set expand = true while the None branch set expand = false. Since derivedProjects should always be invoked for the root project regardless of whether it was explicitly defined or auto-generated, both branches should behave the same way. Eliminating the variable makes this intent clear.
2026-04-04 14:55:42 -04:00
Dream 544f56695a
[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-04-01 11:23:10 +09:00
BrianHotopp 4f06b90534
[2.x] fix: Write maven-metadata-local.xml during publishM2 for SNAPSHOTs (#8996)
publishM2 never wrote maven-metadata-local.xml, which Maven uses to
distinguish local installs from remote artifacts. Without it, Maven
re-downloads remote SNAPSHOTs even when a local copy exists, making
publishM2 effectively broken for SNAPSHOT workflows.

Fixes #2053

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 01:58:57 -04:00
Dream 3dd7f939cf
[2.x] fix: Scope dependencyMode filtering to compilation only (#8990)
**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
2026-03-29 23:13:06 -04:00