Commit Graph

17728 Commits

Author SHA1 Message Date
eugene yokota 40ef381fa2
[2.x] ExtendedRunnerTest (#8674)
Problem/Solution
Looks like this needs to be reformatted.
2026-02-01 22:25:10 -05:00
bitloi a76074a602
[2.x] fix: skip writing sbt.version in scripted test directories (#8673)
**Problem**

1. Write a scripted test that runs sbt in that test.
2. sbt writes `sbt.version` under `project/build.properties`, which acts as a test filter.
3. The test setup is implicitly altered.

**Solution**

Before writing `build.properties`, sbt checks whether the base directory is inside a scripted test directory (path contains `sbt-test`). If so, it skips writing so the test setup is not altered.
2026-02-01 18:02:17 -05:00
eugene yokota afc9a90374
[2.x] fix: Fix subproject evaluation order (#8672)
**Problem**
Subproject definition is ordered bottom-to-top.

**Solution**
Fixes the definition to be top-to-bottom.
2026-02-01 02:33:11 -05:00
bitloi 4430d4c553
[2.x] feat: add rootProject macro (#8671)
Add a rootProject convenience macro that expands to a Project with base "."
and the enclosing val name as id. Allows writing `val root = rootProject`
instead of `val root = (project in file("."))` for a stable root project id.
2026-02-01 01:07:10 -05:00
eugene yokota 080ce8f00e
[2.x] Extend 2.x universe to BinCompatV (#8667)
**Problem**
Some scripted tests are failing due to the fact that -bin-SNAPSHOT
isn't being recognized.

**Solution**
This fixes sbtApiVersion to recognize BinCompatV.
2026-01-31 23:29:50 -05:00
eugene yokota 5b2881e15e
Merge pull request #8668 from bitloi/fix/3616-resolve-this-project
[2.x] feat: Support ThisProject in aggregate and dependencies
2026-01-31 23:29:13 -05:00
bitloi 3de8704bd3 WorkerMain: exit quietly on invalid JSON-RPC input (no stack trace)
When input lacks 'jsonrpc' field (e.g. {}), call System.exit(1) instead
of throwing IllegalArgumentException. Avoids noisy stack traces in
CI from WorkerExchangeTest's intentional bad-input tests.
2026-02-01 02:33:41 +01:00
bitloi 4dfe68a681 fix: Resolve ThisProject to empty to avoid cycle in aggregate/deps DAG
Resolving ThisProject to ProjectRef(uri, p.id) created a self-reference
in the aggregate (and dependency) list. BuildUtil.checkCycles runs
topological sort on this relation and throws Cyclic when it sees the
self-loop.

Treat ThisProject as no-op: resolve to Vector.empty so the build loads
without error. aggregate(ThisProject) / dependsOn(ThisProject) is
effectively a no-op (self is already included).
2026-02-01 01:59:46 +01:00
bitloi 1a6039c17a Handle ThisProject in aggregate and dependencies
Fixes #3616 - Scope's resolveProjectBuild and resolveProjectRef
mishandle ThisProject.

Previously, using ThisProject in aggregate() or dependsOn() would
cause a runtime error: 'Cannot resolve ThisProject w/o the current
project'.

This change adds proper handling for ThisProject in Load.scala:
- In checkAll: Skip validation for ThisProject (refers to self)
- In resolveProjects: Resolve ThisProject to ProjectRef(uri, p.id)
2026-02-01 01:06:07 +01:00
eugene yokota a6e4c9c3c1
[2.x] Bump to 2.0.0-RC9-bin-SNAPSHOT (#8666) 2026-01-31 18:23:07 -05:00
bitloi d633de5c3f
[2.x] fix: Detect alias/task key name conflicts (#8659)
Problem
When a user defines an alias with a name that matches an existing task or setting key (e.g., `alias c = compile` when a custom task `c` exists), the alias silently wins and shadows the task.

Solution
Detect conflicts at alias creation time and fail with an error message:
```
Alias 'c' conflicts with a task or setting key of the same name. Use a different alias name to avoid ambiguity.
```
2026-01-31 17:56:42 -05:00
eugene yokota 9388c140fa
[2.x] test: Move back the project scripted tests (#8660)
**Problem**
"project" scripted tests are commented out into "project1" directory.

**Solution**
This brings them back, while some remain pending.
2026-01-31 17:41:45 -05:00
bitloi 1ad6b88742
[2.x] feat: Per-channel project cursor for multi-client server mode (#8649)
**Problem**
When multiple clients connect to the same sbt server, they all share the same "current project" state. When one client switches projects with `project X`, all other clients see that change.

**Solution**
Store per-channel project cursors in State attributes. Each client maintains its own cursor that tracks which project it has selected.
2026-01-29 23:15:39 -05:00
PandaMan 461e12d497
[2.x] fix: Handle paths with parentheses in sbt.bat on Windows (#8656)
Windows CMD interprets parentheses as special syntax for command grouping.
When the project directory path contains parentheses (e.g., in username),
the batch script fails with ') was unexpected at this time.' error.

This fix stores the current directory in a variable using delayed expansion
(!CURRENT_DIR!) instead of using %CD% directly, which properly handles
paths containing parentheses and other special characters.

Fixes #8644
2026-01-29 16:51:06 -05:00
eugene yokota f05a96aceb
Update contributing to clarify AI usages (#8657) 2026-01-29 11:56:45 -05:00
bitloi 627c484cd8
[2.x] fix: Restore bincompat for ScriptedRun methods (#8654)
In PR #8621, I added a new `keepTempDirectory` parameter to `ScriptedRun.run()` and `invoke()` methods. To suppress MiMa warnings, I added `mimaBinaryIssueFilters` for:
- `DirectMissingMethodProblem("sbt.ScriptedRun.run")`
- `DirectMissingMethodProblem("sbt.ScriptedRun.invoke")`
- `DirectMissingMethodProblem` for various internal `RunV1`, `RunV2`, `RunInParallelV1`, `RunInParallelV2` classes

However, this broke binary compatibility, which prevents sbt 1.x from calling sbt 2.x for cross-building (building sbt 2.x plugins using sbt 1.x).
2026-01-29 11:07:44 -05:00
NeedmeFordev 81c3d7d6c6
[2.x] fix: Fixes ActionCache tests on Windows (#8628)
Fixes #8627

- Use ${OUT} placeholder and remove StringVirtualFile1 special-case handling
- Make dirZipExt check generic (use vf instead of svf: StringVirtualFile1)
- Let syncBlobs handle StringVirtualFile1 transparently via fileConverter.toPath()
2026-01-28 15:27:46 -05:00
DEBORAH FUNMILOLA OLABOYE a66a3064f9
[2.x] fix: Display HTTP response body when bundle upload fails (#8630)
When a bundle upload to Central Portal fails, the error now displays the HTTP response body instead of just the status code. This provides more useful debugging information, as the response body typically contains detailed error messages from the server.
2026-01-28 10:36:45 -05:00
bohdansolovie aa4ac5b981
[2.x] fix: Add null check for resource URL in ResourceLoader.getPropertiesFor (#8641)
**Problem**
getPropertiesFor method calls getResource().openStream() without checking
if getResource returns null. When a resource doesn't exist, this causes
a NullPointerException with no context about which resource was missing.

**Solution**
Added null check before calling openStream() and throw a descriptive
FileNotFoundException with the resource name if the resource is not found.
This prevents NullPointerException and provides better error messages.

Generated-by: Auto
2026-01-28 10:05:03 -05:00
eugene yokota cc0915fed9
[2.x] refactor: Scala Instance (#8648)
**Problem**
Strings are used to pass paths around.

**Solution**
This cleans up the Scala instance construction code.
2026-01-28 02:27:57 -05:00
calm 5789a7ef77
[2.x] feat: Implement ivyless publishLocal (#8634)
Fixes #8631

**Changes:**
- Add `useIvy` setting key (defaults to `true`)
- Add `ivylessPublishLocalImpl` helper that publishes without Ivy
- Modify `publishLocal` to use ivyless publisher when `useIvy := false`
- Generate ivy.xml via `lmcoursier.IvyXml`
- Generate MD5/SHA-1 checksums for all files
- Add scripted test `dependency-management/ivyless-publish-local`
2026-01-27 00:05:43 -05:00
dive2tech cf8899919d
[2.x] Fix potential division by zero in CacheEventLog.toSummary (#8635)
Add guard to prevent division by zero when calculating hitRate.
If total is 0, hitRate is set to 0.0 instead of causing NaN or Infinity.
2026-01-26 15:47:16 -05:00
eugene yokota 92b0564dc6
[2.x] fix: Fix scala-reflect not found problem (#8632)
## Problem
We enforce same-version policy for scala-reflect in Scala 2.13.
However due to sandwich dependency, the graph can bump
scala-library to 3.8.1, which is missing scala-reflect counterpart.

## Solution
Drop the same-version policy.
2026-01-26 04:55:07 -05:00
eugene yokota 0a96df6f89
[2.x] docs: Move to CONTRIBUTING (#8629)
To improve the visibility, move the pull request guides
into CONTRIBUTING.md.
2026-01-25 15:48:09 -05:00
calm 9951a302c9
[2.x] feat: Support fork in console task (#8604)
When enabled, the Scala REPL runs in a separate JVM.
2026-01-25 02:16:49 -05:00
eugene yokota ba8c340a2b
Merge pull request #8530 from eed3si9n/wip/scala-3.8.0
[2.x] deps: Update to Scala 3.8.1
2026-01-25 02:07:52 -05:00
Eugene Yokota 1a214cbb72 Drop flaky Ivy test 2026-01-25 01:29:52 -05:00
Eugene Yokota eaada0494d Fix common settings loading 2026-01-25 01:29:09 -05:00
eugene yokota e4b651b3a8
Apply suggestion from @mzuehlke
Co-authored-by: Marco Zühlke <mzuehlke@gmail.com>
2026-01-24 17:25:28 -05:00
Dairus 7a9775c87d
Add integration test for bspConfig & embedded launcher jar (fixes #7794) (#8597)
This adds a scripted integration test to verify that the `bspConfig` task correctly generates a valid BSP connection file (`.bsp/sbt.json`) when the embedded launcher JAR is present in the classpath.
2026-01-24 15:05:51 -05:00
Eugene Yokota 1b9f065c0a CI fixes 2026-01-24 04:52:28 -05:00
Eugene Yokota a8ecbf2e61 Fix lazy val extraction 2026-01-24 04:52:28 -05:00
Eugene Yokota 19ca2911d2 Scala 3.8.1 2026-01-24 04:52:28 -05:00
Eugene Yokota d9bf396bf7 Use JDk 17 for CI 2026-01-24 04:52:28 -05:00
Eugene Yokota 6cf8611dee Scala 3.8.0 2026-01-24 04:52:28 -05:00
Eugene Yokota 9813e60fe3 refactor: Clean up infix etc 2026-01-24 04:52:28 -05:00
bitloi f8704752e0
[2.x] feat: Add scriptedKeepTempDirectory setting (#8621)
**Problem**

When running scripted tests to debug sbt plugins, the temporary directories (`/private/var/folder/...`) are automatically deleted after tests complete. This makes it difficult to inspect the test state for debugging purposes, requiring workarounds like adding `$ pause` commands and manually copying directories.

**Solution**

Added a new `scriptedKeepTempDirectory` setting that allows users to preserve temporary directories after scripted tests complete. When enabled, the temporary directory path is logged so users can inspect it.

Usage:
```scala
scriptedKeepTempDirectory := true
```
2026-01-23 21:22:50 -05:00
bitloi 64dadd6459
[2.x] fix: Throw on addCompilerPlugin(foo % Test) (#8622)
Problem

When using `addCompilerPlugin((dependency) % Test)`, the compiler plugin was incorrectly added to BOTH `test:scalacOptions` AND `compile:scalacOptions`, instead of only `test:scalacOptions`.

Solution

Throw when the dependency is scoped, since we do not support this use case.
2026-01-23 11:41:16 -05:00
calm 8a518dfb98
[2.x] fix: Skip eviction warning when winner satisfies version range (#8616)
- Add `versionSatisfiesRange()` function to `VersionRange.scala` supporting Maven-style ranges (`[x,y)`, `(x,y]`, `[x,)`, etc.) and plus ranges (`1.0+`)
- Check if winner version satisfies evicted module's version range in `guessCompatible()`
2026-01-22 15:52:58 -05:00
calm 398af2eaaa
[2.x] fix: Suppress "Multiple main classes" warning for runMain commands (#8613)
Changed the scope separator parsing from `/` only to `[/:]` to handle both new slash syntax (`Test/runMain`) and old colon syntax (`test:runMain`).
2026-01-22 12:58:53 -05:00
circlecrystalin 55e75faee2
[2.x] fix: Fix flaky client tests (#8580) 2026-01-22 05:35:13 -05:00
calm 2380ab84b6
[2.x] feat: testOnly as a command (#8607)
Adds `testOnly` command that fails when no tests match the specified patterns across all aggregated subprojects.
2026-01-22 04:53:54 -05:00
eugene yokota 089d56c50e
[2.x] doc: tech stack (#8609)
Problem/Solution

Document sbt's tech stack.
2026-01-22 04:20:06 -05:00
calm f4ab500d19
[2.x] fix: Use -external-mappings for Scala 3 doc task #6652 (#8602)
**Problem**

When `autoAPIMappings := true` is set on a Scala 3 project, running `sbt doc` emits warnings:

```
[warn] bad option '-doc-external-doc:/modules/java.base#https://docs.oracle.com/...
```

This happens because Scala 3's scaladoc doesn't recognize Scala 2's `-doc-external-doc` option.

Fixes #6652

**Solution**

- Added `Opts.doc.externalAPIScala3` that generates the Scala 3 format: `-external-mappings:regex::[scaladoc3|javadoc]::url`
- Modified `Defaults.scala` to use the appropriate method based on Scala version
- Added heuristics to detect javadoc vs scaladoc based on file/URL patterns
2026-01-22 02:13:10 -05:00
calm c099be5f18
[2.x] fix: Race condition in WorkerExchangeTest.propBye (#8606) 2026-01-22 00:49:41 -05:00
calm 527f109671
[2.x] fix: Lazy cache hostname resolution at object level (#8603)
- Move hostname resolution to object-level lazy val to prevent blocking sbt startup
- On macOS with misconfigured hostname, `InetAddress.getLocalHost.getHostName` can take ~5 seconds due to DNS timeout
- Now resolution only happens once per session and is deferred until tests actually run
2026-01-21 20:01:28 -05:00
calm 37c6eb2cd9
[2.x] test: Add test for sbt --client startup time (#8599)
* Add test for sbt --client startup time
* Skip startup time test on macOS due to slow hostname resolution
2026-01-21 20:00:00 -05:00
MkDev11 2a5746cf6c
[2.x] feat: Add dependency lock file support (#2989) (#8581)
**What it does**

When you run `dependencyLock`, sbt generates a `deps.lock` file that captures your resolved dependencies. This file can be checked into version control to ensure reproducible builds across different machines and CI environments.

**New tasks**

- **`dependencyLock`** - Generates the lock file from the current resolution
- **`dependencyLockCheck`** - Validates the lock file is up-to-date (fails build if stale)

**How it works**

The lock file stores a hash of your declared dependencies and resolvers. When dependencies change, the hash changes, and `dependencyLockCheck` will fail until you regenerate the lock file.

If no lock file exists, `dependencyLockCheck` passes silently - this allows gradual adoption.
2026-01-21 19:08:59 -05:00
calm 1b8e3317f9
[2.x] feat: Add "3-latest.candidate" support for Scala 3 release candidates (#8596)
Add support for `"3-latest.candidate"` to automatically resolve to the latest Scala 3 RC from Maven Central.

```scala
scalaVersion := "3-latest.candidate"
```

Ref https://github.com/sbt/sbt/discussions/8590
2026-01-21 03:42:50 -05:00
calm 642be58d44
Add scripted test for #6175 (#8598)
This PR adds a scripted test to prevent regression of issue #6175, where `MethodHandle.invokeExact` failed to compile on JDK 15+ when using `-release 11`.

Changes:
- Added `sbt-app/src/sbt-test/java/method-handle-release/` scripted test
- Test uses Scala 2.13.16 with `-release:11` to reproduce the original issue scenario
- Verifies that polymorphic signature methods compile correctly under cross-version targeting
2026-01-21 02:31:07 -05:00