Commit Graph

17870 Commits

Author SHA1 Message Date
Matt Dziuban 6e7565d28a [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 21:40:09 -04:00
bitloi a259262262 [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-05-02 21:39:45 -04:00
Eugene Yokota 9bc47864fe [2.0.x] fix: Remove will-be-ignored warning 2026-05-02 21:30:28 -04:00
Renzo 9018c5a718 [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-05-02 21:29:42 -04:00
eugene yokota 06e53a0ae4
[2.0.x] fix: Fix error with "-language:postfixOps" (#9158)
Co-authored-by: kenji yoshida <6b656e6a69@gmail.com>
2026-04-30 01:13:13 -04:00
eugene yokota 5fe73c82fd
[2.x] perf: Use bytecodeHash for incremental test (#9152)
**Problem**
There's perf issue building ClassStamp for the incremental test.

**Solution**
This reuses the bytecodeHash created during compilation.
2026-04-29 23:10:59 -04:00
eugene yokota 7b7aba5245
[2.0.x] Update to Zinc 2.0.0-M16 (#9145) 2026-04-27 04:15:15 -04:00
eugene yokota ec497c38ca
[2.0.x] fix: Remove will-be-ignored warning (#9144)
**Problem**
run warns about jvm option not being applied,
but it is applied for client-side run.

**Solution**
Remove the warning.
2026-04-27 04:14:12 -04:00
eugene yokota cecf8bd6c2
[2.x] Bump sbtn to 2.0.0-RC13 (#9141) 2026-04-27 01:23:55 -04:00
eugene yokota b441710fd4
Merge pull request #9142 from eed3si9n/bport/scripted
[2.0.x] bport: Expose scripted / excludeFilter
2026-04-27 01:18:58 -04:00
eugene yokota d59a2be85a [2.x] refactor: Replace string Array with ju.List (#9138)
**Problem**
Scala 3 supposedly has problem with String array in structural types.

**Solution**
This works around the issue by using ju.List.
2026-04-27 00:40:45 -04:00
Ali Rashid 30aded8ced [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-27 00:40:03 -04:00
eugene yokota 56c3fdbd0b
[2.0.x] fix: Fixes compilerPlugin(...) to ignore platform (#9135) (#9136)
**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 19:03:55 -04:00
eugene yokota 03c371db5e
[2.0.x] Add Test configuration to evictionWarningOptions (#9134)
* 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.

Co-authored-by: Zainab Ali <zainab.ali.london@gmail.com>
2026-04-26 13:37:00 -04:00
eugene yokota 9e2cc51579
[2.0.x] fix: Fixes managedScalaInstance false support (#9121) (#9124)
**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 03:19:20 -04:00
eugene yokota 5de1057488
[2.0.x] hide JDK warnings if JDK 26 or later (#9119)
Co-authored-by: kenji yoshida <6b656e6a69@gmail.com>
2026-04-21 23:40:39 -04:00
eugene yokota 1dc197dc27
[2.0.x] Update sbtn version to package (#9090) 2026-04-15 02:59:43 -04:00
Eugene Yokota c0dc4eb660 sbt 2.0.0-RC12 2026-04-13 03:00:27 -04:00
eugene yokota f2e1bf8be6
Merge pull request #9082 from eed3si9n/bport2/client-side-run-fix
[2.0.x] Backport sbtn related fixes
2026-04-13 01:31:07 -04:00
eugene yokota e8757c85e2 [2.x] fix: Fixes client-side run status (#9081)
**Problem**
In sbt 2.x, if we execute a run task from the shell,
and if the program fails, it ends up taking down the entire shell
because client-side run rethrows, which is not desirable
for the sbt shell.

**Solution**
1. Omit printing out success for ClientJobParams, which is the runinfo.
2. Print out success or error on the client-side for shell usage case.
2026-04-13 00:45:39 -04:00
BitToby e64db7927c [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-13 00:45:09 -04:00
Matthias Kurz e515decfc5
[2.x] add no-op addDependencyTreePlugin shim for migration (#9067) 2026-04-12 14:02:05 -04:00
eugene yokota 53b36840bb
[2.0.x] Fix Scala 3 .previous expansion for unstable path (#9041) (#9075)
**problem**
.previous was implemented as an inline expansion to wrapInitTask(Previous.runtime(in)(<instance of JsonFormat[A1]))

For example, the .previous on taskKey[String] gets inlined like
this, and then sbt's macro moves `Previous.runtime(...)(using StringJsonFormat)` into task input.

lazy val fingerprints = taskKey[String]("...")
val previousFingerprints = fingerprints.previous

// inlined
val previousFingerprints: Option[String] = {
  InputWrapper.wrapInitTask(
    Previous.runtime(...)(using StringJsonFormat)
  )
}

- 6c8ee6ea37/main-settings/src/main/scala/sbt/Def.scala (L410-L412)
- 6c8ee6ea37/core-macros/src/main/scala/sbt/internal/util/appmacro/Cont.scala (L468)

However, if the return type of task is a bit more complicated like
Seq[String], it doesn't work:

Scala 3 Compiler's inliner creates a synthetic proxy symbol if the
inlining tree is an application, whose arguments are unstable path.

For example,

lazy val fingerprints = taskKey[Seq[String]]("...")
val previousFingerprints = fingerprints.previous

// inline to
val previousFingerprints: Option[Seq[String]] = {
  val x$2$proxy1 = immSeqFormat(StringJsonFormat)
  InputWrapper.wrapInitTask(
    Previous.runtime(...)(using x$2$proxy1)
  )
}

cc7d6db700/compiler/src/dotty/tools/dotc/inlines/Inliner.scala (L324-L329)

However, sbt2's Cont macro captures only `Previous.runtime(...)(using x$2$proxy1)`, while it doesn't capture the proxy definition. Consequently, while sbt macro moves the `Previous.runtime(...)` application as a task input, the proxy definition is left in the task body.

mapN(
  (
    link / fingerprints,
    Previous.runtime(...)(using x$2$proxy1) // here x$2$proxy1 can't be found
  )
) {
  ...
  val x$2$proxy1 = ...
}

Then we get:

-- Error: /.../build.sbt:14:59
14 |  val previousFingerprints = (link / fingerprints).previous
   |                                                           ^
   |While expanding a macro, a reference to value x$2$proxy1 was used outside the scope where it was defined

**How this PR fixed**
This commit fixes the problem by defining a dedicated Scala3 macro for .previous that summon JsonFormat[A1] inside the macro before constructing the wrapped previous.runtime(...)(using ...) by inliner. The macro insert the found given value tree directly into the previous.runtime(...)(using $found).

This way, Cont macro always moves the Previous.runtime tree along with it's given argument, without leaking compiler-generated inline proxies across scopes.

Co-authored-by: Rikito Taniguchi <rikitotaniguchi@proton.me>
2026-04-12 06:26:19 -04:00
eugene yokota 879ef86567
[2.0.x] fix: Scope dependencyMode filtering to compilation only (#8990) (#9074)
**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

Co-authored-by: Dream <42954461+eureka928@users.noreply.github.com>
2026-04-12 06:25:55 -04:00
eugene yokota 542591ea20
[2.0.x] Remove Path type from caching (#9036)
**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 23:10:27 -04:00
eugene yokota 91be1a2f7e
[2.x] fix: resolve virtual path in -Ypickle-write scalac option (#9011) (#9035)
earlyOutput is a virtual file reference, so passing it directly via
.toString produces a virtual path that scalac cannot resolve. Use
fileConverter.value.toPath() to convert it to an actual filesystem path.

Co-authored-by: corevibe555 <45244658+corevibe555@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 23:09:13 -04:00
eugene yokota 372b945651
Merge pull request #9031 from eed3si9n/bport2/metabuild
[2.0.x] fix: Fixes metabuild reloading
2026-04-05 22:27:20 -04:00
eugene yokota 75edb0afe0 [2.0.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 22:02:21 -04:00
eugene yokota c89f14caa1 [2.x] fix: Fixes pollInterval (#9020)
**Problem/Solution**
checkBuildSources / pollInterval should just fallback to some value.
2026-04-05 22:01:44 -04:00
eugene yokota 5469e046fa
[2.0.x] Prefer local ScalaModuleInfo over global config (#9028) (#9030)
Otherwise, a user will never be able to download scala library at any
other version.

Co-authored-by: Albert Meltzer <7529386+kitbellew@users.noreply.github.com>
2026-04-05 21:55:37 -04:00
eugene yokota 872985dcf4
[2.0.x] Fixes the source dependency fix (#8982)
**Problem/Solution**
Run was missing cwd.
2026-03-25 01:17:11 -04:00
eugene yokota e382084bbf
[2.0.x] Zinc 2.0.0-M15 (#8981) 2026-03-25 01:16:46 -04:00
eugene yokota 1d77704ea3
[2.0.x] feat: Add dependencyMode setting to control classpath transitivity (#8960) (#8972)
**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

Co-authored-by: Dream <42954461+eureka928@users.noreply.github.com>
2026-03-24 00:39:25 -04:00
eugene yokota 3d224539a2
Merge pull request #8970 from eed3si9n/bport/cve-fix
[2.0.x] bport: Harden Windows VCS URI fragments against command injection
2026-03-23 23:59:52 -04:00
Anatolii Kmetiuk 0529df8795 Allowlist-based approach to VCS string sanitization 2026-03-23 23:32:54 -04:00
Anatolii Kmetiuk e32e2455c9 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
2026-03-23 23:32:37 -04:00
eugene yokota 11ff106a70
Merge pull request #8964 from eed3si9n/bport/network-client
[2.0.x] bport: sbtn-related changes
2026-03-23 00:19:38 -04:00
BitToby ce638e7a0f 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-22 23:57:15 -04:00
chrisrock1124 bf6bd68a96 [2.x] fix: sbt --client fails if -mem is provided (#8831)
The bash launcher's runNativeClient() passed all original CLI args to
sbtn, only stripping --client. This caused sbtn to receive launcher
flags like -mem 10000, which NetworkClient.parseArgs() misclassified:
-mem went to sbtArguments and 10000 went to commandArgs, resulting in
a broken server start command.
2026-03-22 23:50:24 -04:00
eugene yokota ef9c5bfc9c
[2.0.x] Add VF keys (#8963)
**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-22 23:35:22 -04:00
eugene yokota 8f41553a32
Merge pull request #8962 from eed3si9n/bport/coursier-update
[2.0.x] bport: Update to Coursier 2.1.25-M24
2026-03-22 22:39:13 -04:00
eugene yokota cd343c4cc6 [2.x] fix: Fixes non-typelevel scalaOrganization (#8945)
**Problem**
Coursier used to support only org.typelevel as scalaOrganization override.

**Solution**
This uses the newly added parameter in M24.
2026-03-22 22:09:11 -04:00
bitloi f5261d9e08 [2.x] fix: Skip Conflict when dependency relocations form a cycle (#8919)
**Problem**
Coursier graph.Conflict -> DependencyTree relocation can loop forever when
Maven/Gradle relocation metadata forms a cycle (sbt-site 1.4.1).

**Solution**
Detect relocation cycles with the same step logic as Coursier, skip Conflict
for affected configs, log once per update.

Generated-by: Claude
2026-03-22 22:08:42 -04:00
Michał Pawlik 972cc30ce1 [2.x] fix: use new constructor for CantDownloadModule (#8905) 2026-03-22 22:07:58 -04:00
Michał Pawlik 29d2653bf6 [2.x] Retry on HTTP 5xx during dependency resolution (#8903) 2026-03-22 22:07:31 -04:00
eugene yokota 1bd5a5e409 [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-22 22:05:09 -04:00
eugene yokota db41205098
[2.0.x] fix: Unresolved dependency error for Coursier (#8869) (#8961)
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

Co-authored-by: bitloi <89318445+bitloi@users.noreply.github.com>
2026-03-22 21:53:20 -04:00
eugene yokota 023d3ba2c5
[2.0.x] Hide projectDescriptors (#8959)
**Problem**
projectDescriptors key depends on Ivy, and will be removed.

**Solution**
This hides the key in 2.0.x branch.
2026-03-22 02:15:37 -04:00
eugene yokota 6ddbf38d9a
[2.0.x] fix: Fix TaskConvert.appExpr (#8955)
Co-authored-by: kenji yoshida <6b656e6a69@gmail.com>
2026-03-21 17:30:46 -04:00
eugene yokota cf94c29478
[2.0.x] fix: fall back to the onsite task when cache fails (#8890) (#8954)
**Problem**
When the remote cache server (e.g. bazel-remote using S3 for storage) reports an AC (Action Cache)
hit but the underlying CAS (Content Addressable Storage) blob is missing or
corrupt, ActionCache.cache propagates the resulting exception (typically
java.io.FileNotFoundException) directly to the SBT task engine process with no interception of the propogated error.
This causes a build failure instead of a graceful cache miss.

The three unguarded call sites are:
1. organicTask - syncBlobs after a successful put only caught NoSuchFileException,
   missing FileNotFoundException and other IO errors.
2. getWithFailure / readFromSymlink fast-path - syncBlobs inside flatMap with no
   exception handling.
3. getWithFailure main branch - both syncBlobs calls and the subsequent IO.read
   were completely unguarded.

**Solution**
Guard all three call sites with NonFatal catches:
- Cache read failures (getWithFailure) return Left(None) which the caller
  interprets as a cache miss, triggering organic recomputation.
- Cache write failures (organicTask) are demoted to a debug-level log; the task
  result that was already computed is returned successfully.

Two regression tests are added to ActionCacheTest:
1. Tests the main getWithFailure branch using the default relative-path converter.
2. Tests the readFromSymlink fast-path using an absolute-path converter so the
   symlink created on the first run is found by Files.isSymbolicLink on the second.

Co-authored-by: Idan Ben-Zvi <idanbenzvi@users.noreply.github.com>
2026-03-21 17:29:46 -04:00