Commit Graph

3786 Commits

Author SHA1 Message Date
MkDev11 6f14de514b
[2.x] feat: Add setup-java action support in CrossJava (#8574)
Add SetupJavaDiscoverConfig to detect JDKs installed by GitHub's
setup-java action at paths like:
- /opt/hostedtoolcache/Java_Zulu_jdk/25.0.1-8/x64 (Linux)
- C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.29-7\x64 (Windows)

These JDKs are now available in fullJavaHomes as zulu@25.0.1,
temurin@11.0.29, etc.

Supported vendors: Zulu, Temurin, Adopt, Corretto, Liberica,
Microsoft, Semeru. Temurin-Hotspot and Adopt are normalized to
temurin.

Fixes #8582

* test: Refactor setup-java tests to use real directory structure

---------

Co-authored-by: mkdev11 <noreply@users.noreply.github.com>
2026-01-20 09:35:43 -05:00
byteforge c5af677632
[2.x] feat: Support ... as testOnly pattern (#8577) 2026-01-19 18:45:29 -05:00
E.G 402619fc45
[2.x] fix: Format Seq values consistently in multi-project builds (fixes #7339) (#8567)
When running commands like 'Test/definedTests' on multi-project builds,
the output was showing raw Vector(...) format instead of nicely formatted
per-item output.

Before:
  [info] svc / Test / definedTests
  [info]   Vector(Test FooSpec : ..., Test BarSpec : ..., ...)

After:
  [info] svc / Test / definedTests
  [info]   * Test FooSpec : ...
  [info]   * Test BarSpec : ...

The fix extends printSettings to check if values are Seq types in
the multi-project case and format each item on its own line with
a '* ' prefix, matching the single-project behavior.
2026-01-17 14:37:42 -05:00
eugene yokota 8b4b89c395
[2.x] Disable delegation on shell (#8539)
**Problem**
Currently the shell delegates request tasks even when a non-existent
task like Compile / update is requested.

**Solution**
This removes the delegation, if the input key is scoped, so it will fail.
We will, however, continue to delegate on the subproject axis,
since it's useful to use Global or ThisBuild scoping.
2026-01-17 00:05:21 -05:00
bitloi c832fad7b5
[2.x] feat: Notify sbtn client when command is queued (#8568)
Fixes #8356

**Problem**

When `sbtn` sends a command while another long-running task (like `console`) is already executing, the client silently blocks with no indication that the command is waiting in a queue.

**Solution**

When a new command arrives via the network channel and another command is currently running, the server now sends an `ExecStatusEvent` notification with status `"Queued"` to the client. The client displays a message like:

```
[info] waiting for: console
```
2026-01-16 16:17:00 -05:00
Pegasus 79c60ca4c1
[2.x] fix: Allow dependencyTree to run despite eviction errors (#8554)
**Problem**
When binary compatibility eviction errors occur, users cannot run
`dependencyTree` to debug the dependency conflict because it fails
with the same eviction error.

**Solution**
Set `evictionErrorLevel` and `assumedEvictionErrorLevel` to `Level.Warn`
for the `dependencyTreeIgnoreMissingUpdate` task, allowing the dependency
tree to be displayed even when eviction errors are present.

Fixes #7255
2026-01-15 22:52:38 -05:00
E.G 009b0e1276
[2.x] test: Migrate FileStampJsonSpec.scala to verify.BasicTestSuite (#8552)
Co-authored-by: GlobalStar117 <GlobalStar117@users.noreply.github.com>
2026-01-15 15:01:57 -05:00
MkDev11 b58c0fb37f
[2.x] fix: Cleanup child processes on sbt exit (#8532)
When using fork := true, sbt spawns child processes that may become
stale if cancelled. Previously, these processes were not cleaned up
when running the exit command.

This fix adds RunningProcesses.killAll() to the shutdown hook so that
all tracked forked processes are terminated when sbt exits.

Fixes #7468
2026-01-14 15:57:50 -05:00
MkDev11 f85ced45f2
[2.x] fix: Start server when explicitly requested via BSP/thin client (#8529)
Fixes #7481

When sbt is started by a remote client (BSP or thin client via --server flag),
always start the server regardless of autoStartServer setting. The autoStartServer
setting is meant for automatic server startup, not for blocking explicit server
start requests.
2026-01-14 04:57:05 -05:00
MkDev11 7b33362245
[2.x] fix: Preserve user-defined scalacOptions in doc task scope (#8528)
Fixes #7482
2026-01-14 00:57:42 -05:00
MkDev11 82e370b4cb
[2.x] fix: inputFileChanges with nested task scopes (#8516)
Fixes #7489

When using nested task scopes like otherTask / testTask, the
inputFileChanges macro was returning the wrong scope. It checked
if the scope already had a task axis and returned it as-is, but
this meant it would use otherTask's scope instead of testTask's.

The fix always sets the task axis to the key being queried,
ensuring fileInputs settings are found at the correct scope.
2026-01-14 00:10:23 -05:00
SID 0c6b4c9741
[2.x] Fix watchTriggers to control what triggers instead of adding to fileInputs (#8525)
When watchTriggers is explicitly set (non-empty), use only watchTriggers
instead of combining them with fileInputs. This allows users to control
what triggers the watch by setting watchTriggers.

Fixes #7130
2026-01-13 21:14:10 -05:00
Satoshi Dev 43e0428bed
[2.x] fix: trim whitespace from sbt.version in build.properties (#8524)
When sbt.version in build.properties has trailing whitespace,
sbt incorrectly reports a version mismatch even after reboot.

This fix trims the property value in all places where sbt.version
is read from build.properties:
- Main.scala (version mismatch warning)
- MainLoop.scala (clean command version detection)
- ScriptedTests.scala (test compatibility check)

Fixes #8103
2026-01-13 21:13:47 -05:00
kenji yoshida eb81ff9000
[2.x] deprecate useLog4J SettingKey (#8523) 2026-01-13 18:46:41 -05:00
Match 727f4b05c6
fix: Fix NoClassDefFoundError after changing val in build.sbt (#8521)
**Problem**

When a val definition in build.sbt changes and the user runs `reload`, sbt crashes with `NoClassDefFoundError: $Wrap<hash>$`.

```
java.lang.NoClassDefFoundError: $Wrape8743d4f36$
  at $Wrap0b8ea34d40$.$anonfun$1(build.sbt:1)
```

The workaround was to delete `project/target` directory.

**Solution**

The root cause was that imports were not included in the hash calculation when evaluating build.sbt expressions. When a val definition changes:
1. Its `$Wrap` module gets a new hash
2. Settings that reference the val get new imports pointing to the new module
3. But if the setting expression didn't change, its hash was the same
4. The old cached class was loaded with bytecode referencing the old module

Fix: Include imports in the hash calculation in `Eval.evalCommon`. Also re-enable `cleanEvalClasses` in `Load.scala` which was disabled pending this fix.
2026-01-13 18:45:16 -05:00
Dairus 4a36171138
[2.x] fix: Fix whatDependsOn RuntimeException (#8462)
Filters out empty versions during parser construction to prevent RuntimeException when creating token parsers.  Includes comprehensive test coverage for edge cases.

DependencyTreePlugin is an AutoPlugin with trigger = AllRequirements,
so it loads automatically in scripted tests without requiring explicit
plugin configuration.
2026-01-13 17:12:57 -05:00
SalesforcePeak 1ef5823a49
[2.x] fix: Log created in Commands not whowing up in WARN or ERROR Log Levels (#8515) 2026-01-13 14:45:15 -05:00
MkDev11 f2a5ae7219
[2.x] fix: Use strict matching for scala-library jar detection (#8507)
Fixes #7511

The previous check used contains("scala-library") which incorrectly
matched any jar with that substring anywhere in the filename, causing
user libraries named like "my-scala-library-foo" to be misclassified
as the Scala standard library and filtered from the classpath.

Changed to use exact match (scala-library.jar) or prefix match
(scala-library-*) to only match the actual Scala library jars,
consistent with how scala-reflect is detected on line 199.
2026-01-12 23:50:01 -05:00
Satoshi Dev 3a9e1ec725
[2.x] fix: Fix pipelining flags applied to unsupported Scala versions (#8499)
Scala 2.x has supported pipelining since 2020. The fix now allows:
- All Scala 2.x versions (pipelining supported)
- Scala 3.5.0+ (pipelining added in 3.5)

Generated-by: AI-assisted
2026-01-12 22:44:49 -05:00
Saber aeabb90d2d
[2.x] feat: dependencyLicenseInfo (#8506)
* Add JSON output support to dependencyLicenseInfo

- Add LicenseInfo rendering object with text and JSON output
- Add dependencyLicenseInfo input task key
- Implement dependencyLicenseInfo task with JSON format support
- Supports --out option for file output
- Auto-detects JSON format from .json file extension
- Follows same pattern as dependencyTree task

Resolves #7771
2026-01-12 22:16:40 -05:00
MkDev11 847703cd5e
[2.x] fix: Allow ++ command to accept project/command patterns not in current state (#8505)
When using '++version project/task', the parser now accepts project/command
patterns (e.g., 'docs/docusaurusPublishGhpages') even if the project doesn't
exist in the current state. This is achieved by adding a fallback parser
that accepts any 'project/command' pattern alongside the combinedParser.

Previously, '++2.12.19 docs/task' would fail with 'Project not found' if
'docs' project wasn't available in the current Scala version, but
'++2.12.19; docs/task' worked. Now both syntaxes work correctly.

The fix is targeted to only accept slash-delimited patterns, avoiding
interference with other parser components like the -v verbose flag.

Fixes #7574
2026-01-12 22:14:01 -05:00
MkDev11 81b6408f49
[2.x] feat: Add csrLocalArtifactsShouldBeCached setting for caching local artifacts (#8504)
This adds a new setting  that allows users to
configure Coursier's FileCache to cache local file:// artifacts. When enabled,
artifacts from local repositories are copied to the cache directory, which is
useful for scenarios like bundling compiler artifacts in a local repo for
offline use.

Fixes #7547
2026-01-12 19:17:55 -05:00
calm ebc11f04a7
[2.x] fix: Fix updateSbtClassifiers using wrong Scala version for cross-built plugins (#8495)
**Problem**

When cross-building sbt plugins with explicit `scalaVersion` set in `build.sbt`, the `updateSbtClassifiers` task fails because it uses the launcher's Scala version instead of the appropriate Scala version for the target sbt version.

For example, with this configuration:
```scala
lazy val root = (project in file("."))
  .enablePlugins(SbtPlugin)
  .settings(
    scalaVersion := "2.10.7",  // Explicit for IDE support
    crossSbtVersions := Seq("0.13.17", "1.0.0"),
  )
```

Running sbt "show updateSbtClassifiers" would fail with:
Error downloading org.scala-sbt:scripted-plugin_2.12:0.13.17

It should look for scripted-plugin_2.10:0.13.17 since sbt 0.13.x uses Scala 2.10.

**Solution**

Modified sbtClassifiersTasks in Defaults.scala to:
1. Check if the project is an sbt plugin (sbtPlugin.value)
2. For plugins, derive the Scala version from pluginCrossBuild / sbtBinaryVersion using PluginCross.scalaVersionFromSbtBinaryVersion
3. For non-plugins, continue using the launcher's Scala version (original behavior)
2026-01-12 16:19:24 -05:00
calm b4f73c9a7b
[2.x] fix: Invalidate update cache across commands when dependencies change (#8501)
**Problem**
When project A's dependencies changed and A was compiled in one command, project B (depending on A) would not invalidate its update cache in a subsequent command. This caused stale classpaths.

The root cause was that `depsUpdated` only checked `!stats.cached`, which only detected fresh resolves within the same command. When a dependency was served from cache (even if resolved fresh in a previous command), `cached` was marked `true`, causing incorrect cache reuse.

Debug scenario from issue:
sbt:aaa> clean
sbt:aaa> a/compile
sbt:aaa> show itTests/depsUpdated
[info] * false   <-- BUG: should be true

**Solution**
Added `stamp: String` field to `UpdateStats` that records when the update was resolved. This stamp persists across commands and enables accurate cross-command comparison:

- If any dependency's stamp > our cached stamp, we re-resolve
- Falls back to `!cached` check for backwards compatibility with old caches
- Using `String` type allows future transition from timestamps to content hashes
2026-01-12 16:17:51 -05:00
MkDev11 add43bd230
feat: Set terminal window title when running applications (#8492)
Set window title to 'sbt <command>: <org> % <name> % <version>' when
running sbt run, runMain, bgRun, or bgRunMain.

For server-side runs, window title is set directly. For client-side runs (sbtn), window title is passed via RunInfo protocol
and set by NetworkClient.

Fixes #7586
2026-01-12 02:32:52 -05:00
calm e7323171a2
fix: Handle relocated dependencies in dependencyTree (#8400) (#8489) 2026-01-11 21:27:11 -05:00
MkDev11 4fba87a757
fix: Filter out JAR paths in BSP diagnostics on Windows (#8482)
When Java compiler generates warnings about missing annotations from
JAR files, the path format is jar:file:///C:/... which causes
InvalidPathException on Windows due to the : character.

The fix filters out jar: paths in toDocument(), similar to how fake
positions like <macro> are already filtered out. This prevents the
exception and allows compilation to continue.

Diagnostics for files inside JARs are not shown in the IDE, which is
correct behavior since they cannot be edited.

Fixes #7665

Generated-by: Cascade (AI pair programmer)
2026-01-11 16:37:13 -05:00
eugene yokota 81d3527913
Merge pull request #8468 from xuwei-k/tailrec-annotation
[2.x] Add `@tailrec` annotation
2026-01-11 03:19:19 -05:00
eugene yokota 271caaab37
Merge pull request #8471 from xuwei-k/BuildServerProtocol-nowarn
[2.x] Fix warnings in BuildServerProtocol.scala
2026-01-11 03:19:03 -05:00
xuwei-k 5667a46749 Fix warnings in BuildServerProtocol.scala 2026-01-11 16:50:36 +09:00
xuwei-k 3b4b7effc2 Remove redundant String#toString 2026-01-11 16:46:05 +09:00
xuwei-k c0fe4dfb10 Add tailrec annotation 2026-01-11 16:33:45 +09:00
MkDev11 37ee88d0fb
Merge branch 'develop' into fix/gc-monitor-warning-8002 2026-01-10 12:23:39 -08:00
mkdev11 9be376973d fix: Use 'CPU seconds' to clarify GC time can exceed wall clock
Address review feedback from eed3si9n to make it clearer that GC time
is cumulative CPU time across parallel collectors, which is why it can
exceed wall clock time.

Fixes #8002
2026-01-10 22:23:05 +02:00
mkdev11 1b2bc53bcf fix: Improve GCMonitor warning message clarity
Add 'seconds' unit to GC time and clarify that the percentage
represents cumulative GC pause time across all collectors.

Fixes #8002
2026-01-10 15:03:57 +02:00
Eugene Yokota a921a86440 [2.x] consoleProject
**Problem**
consoleProject doesn't work. REPL doesn't even start.

**Solution**
I made some progress into consoleProject.
At least Scala 3.7 repl session will now start.
The problem is that compiler bridge has not implemented binding,
so we can't forward the sbt build information into the repl.
2026-01-10 02:15:59 -05:00
MkDev11 061145e67b
[2.x] Add testForkedParallelism setting for forked test thread count (#8453)
**Problems**

When running forked tests, sbt uses `Runtime.getRuntime().availableProcessors()` to determine the thread pool size, ignoring `concurrentRestrictions`. This is inconsistent with non-forked parallel tests.

**Expectations**

Users should be able to control the number of parallel test threads in forked mode, similar to how `concurrentRestrictions` works for non-forked tests.

**Notes**

Added a new setting `testForkedParallelism` that allows explicit control:

```scala
testForkedParallelism := Some(2)  // Use 2 threads
testForkedParallelism := None     // Use availableProcessors() (default)
```
2026-01-09 12:43:50 -05:00
calm329 79b54a28ce Fix ParseKeySpec flaky test when task name matches project name (#8326) 2026-01-08 20:55:14 -08:00
eugene yokota b537afee76
Merge pull request #8452 from calm329/fix/8441-jna-nosys-conditional
[2.x] Fix #8441: Allow system JNA on OpenBSD by making jna.nosys conditional
2026-01-08 20:07:22 -05:00
calm 8c20401fb9
[2.x] Report eviction errors for Test dependencies (#8451)
Eviction warnings and errors were not reported for Test dependencies because
`EvictionError` only checked the Compile configuration.

This fix runs the eviction check for both Compile and Test configurations
separately, with distinct error messages:

- Compile: `found version conflict(s) in library dependencies`
- Test: `found version conflict(s) in Test dependencies`
2026-01-08 20:01:18 -05:00
calm329 1054ee851e Fix #8441: Allow system JNA on OpenBSD by making jna.nosys conditional 2026-01-08 15:19:36 -08:00
Francluob 4976ec7dc7 Fix #8344: Skip interactive prompt in batch mode when project loading fails
When project loading fails in batch mode, sbt was showing an interactive
prompt asking the user to choose between retry, quit, last, or ignore.
However, in batch mode there is no interactive terminal, causing the
process to hang waiting for input that will never come.

This fix checks if we're in batch mode (Prompt.Batch) and automatically
exits with failure (equivalent to 'q' quit option) without prompting the
user. This prevents infinite retry loops on persistent errors and allows
batch mode scripts to fail fast, which is appropriate for CI/CD environments.

The interactive behavior remains unchanged for non-batch mode.
2026-01-08 19:29:35 +01:00
aka James4u a4ad73ddf6
fix: prevent server boot when --no-server is used (#8444)
* fix: prevent server boot when --no-server is used
* refactor: move serverAutoStart to sysprops
* refact: scalafmt
2026-01-07 15:11:04 -05:00
Eugene Yokota e3f99d39cb Merge branch '1.12.x' into wip/merge-1.12.x 2026-01-05 00:08:21 -05:00
Eugene Yokota 0a15069e83 Show warnings when scalaVersion is missing
**Problem**
There's a disconnect between what is perceived to be the current
Scala version, and what sbt uses internally, and thus what it
chooses to be the default scalaVersion.

**Solution**
This displays a warning if scalaVersion setting is missing.
2026-01-04 15:23:05 -05:00
Eugene Yokota 6cb786d010 [2.x] Show warnings when scalaVersion is missing
**Problem**
There's a disconnect between what is perceived to be the current
Scala version, and what sbt uses internally, and thus what it
chooses to be the default scalaVersion.

**Solution**
This displays a warning if scalaVersion setting is missing.
2025-12-27 23:49:43 -05:00
eugene yokota b536bc037d
Merge pull request #8359 from eed3si9n/wip/dependency-tree
[1.x] Use internal config for dependency tree (for Provided)
2025-12-19 01:08:44 -05:00
Eugene Yokota e6492b771e [2.x] fix: Replace Scala version with u when crossPaths is false
**Problem**
sbt 2.x uses crossTarget by default, but it contains Scala version
even when crossPaths is false.

**Solution**
This replaces it with the letter "u" for unspecified.
2025-12-18 00:00:11 -05:00
eugene yokota 26b5ee457f
Merge pull request #8421 from eed3si9n/wip/matrix-cross
[2.x] projectMatrix crossVerson support
2025-12-16 23:45:43 -05:00
Eugene Yokota 4d6ddd50a6 [2.x] projectMatrix crossVerson support
**Problem**
crossVersion is missing from projectMatrix in sbt 2.x.

**Solution**
Port it from sbt-projectmatrix.
2025-12-16 01:33:43 -05:00