Commit Graph

17770 Commits

Author SHA1 Message Date
Eruis2579 391dca6225 fix: Skip native client for --version instead of early handler to prevent hangs (#8717)
Instead of handling --version before native client check (which causes
hangs), skip the native client when --version is set and handle it at
the original location. This avoids interfering with normal execution
flow while still working for sbt 2.x project dirs.
2026-02-10 23:32:24 +01:00
Eruis2579 6232500286 fix: Add defensive checks in --version handler to prevent Windows hangs (#8717)
Add 'if defined' checks before using variables to ensure they're set
before accessing them. This should prevent hangs caused by accessing
uninitialized variables in delayed expansion context.
2026-02-10 22:41:29 +01:00
Eruis2579 2d26055de0 fix: Avoid file I/O in --version handler to prevent Windows hangs (#8717)
Use already-read build_props_sbt_version and is_this_dir_sbt variables
instead of reading build.properties again in the handler. This avoids
file I/O operations that could cause hangs on Windows.
2026-02-10 16:55:44 +01:00
Eruis2579 95a3fc3288 fix: Read build.properties directly in --version handler to avoid hangs (#8717)
Instead of relying on the early build_props_sbt_version read, read
build.properties directly in the --version handler using a local
variable. This isolates file I/O to only when --version is called and
avoids potential interference with normal script execution that could
cause Windows test hangs.
2026-02-10 12:38:20 +01:00
Eruis2579 8251ac544a fix: Use goto :eof for consistency with --script-version handler (#8717)
Use goto :eof instead of goto :end to match the pattern used by
--script-version and other early exits in the batch file. This should
fix the Windows test hang issue.
2026-02-10 12:34:43 +01:00
Eruis2579 1ae2d3af57 fix: Use goto :end for proper cleanup in --version handler (#8717)
Use goto :end instead of goto :eof to ensure @endlocal is called
and the script exits cleanly. This should fix the Windows test hang
when sbtn calls the script.
2026-02-10 11:03:08 +01:00
Eruis2579 14d92b76eb fix: Read build.properties in --version handler to ensure version is available (#8717)
Ensure build_props_sbt_version is read when handling --version flag,
matching the behavior in the batch file and fixing potential CI test failures.
2026-02-10 10:35:00 +01:00
Eruis2579 d11f3623e3 fix: Quote variable assignment to prevent trailing space issues in sbt.bat (#8717) 2026-02-10 09:49:47 +01:00
Eruis2579 b691cfadb2 fix: Use goto :eof for consistency with other early exits in sbt.bat (#8717) 2026-02-10 09:48:05 +01:00
Eruis2579 f7c085ff75 fix: Use goto :eof instead of @endlocal/exit for --version in sbt.bat (#8717)
Using goto :eof is the standard way to exit batch scripts and ensures
proper cleanup. The previous @endlocal/exit approach may have caused
hangs in some scenarios.
2026-02-10 01:19:39 +01:00
Eruis2579 ac95afb145 fix: Fix Windows test hang and assertion mismatch for --version (#8717)
- Fix test to check for correct runner name on Windows (sbt-the-batch-script vs sbt-the-shell-script)
- Fix sbt.bat to properly exit using @endlocal and exit /B 0 instead of goto :eof
2026-02-09 13:30:36 +01:00
Eruis2579 fc804a6575 fix: Handle --version flag in sbt.bat before native client for sbt 2.x (#8717) 2026-02-09 11:58:17 +01:00
Eruis2579 e50e8359e8 test: Add citest2 directory for sbt 2.x integration tests 2026-02-09 10:52:13 +01:00
Eruis2579 96340302ff fix: Add missing import for File extension methods in ExtendedRunnerTest 2026-02-09 10:52:13 +01:00
Eruis2579 34276cc90d test: Add tests for --version flag (#8717) 2026-02-09 10:52:13 +01:00
Eruis2579 9fd98e006a fix: Handle --version flag before native client for sbt 2.x (#8717) 2026-02-09 10:52:13 +01:00
PandaMan b2fea15030
[2.x] fix: Handle CancellationException gracefully with usePipelining (#8718)
When usePipelining is enabled and compilation has errors, CancellationException
was being thrown and showing confusing stack traces to users. This fix catches
the exception in ConcurrentRestrictions.take() and converts it to Incomplete,
which is properly handled by the task execution framework without showing stack
traces.

- Added CancellationException import
- Wrapped jservice.take().get() in try-catch
- Convert CancellationException to Incomplete to prevent stack traces
- Added scripted test to verify the fix

Fixes #7973
2026-02-09 02:28:54 -05:00
PandaMan f47afb5b49
[2.x] fix: Fixes evicted warning for version intervals (#8719)
When a dependency declares a version range (e.g. Ivy [1.3.1,2.3] or comma-separated "1.3.1,2.3" as used by Coursier), and the resolver picks a version inside that range, sbt was still reporting an eviction warning. The chosen version satisfies the range, so it should not be reported as an eviction.

Example (from #6244): oauth2-oidc-sdk and nimbus-jose-jwt both depend on net.minidev:json-smart with range [1.3.1,2.3]. Resolution selects 2.3, which is within the range. Before this fix, sbt reported an eviction for json-smart even though 2.3 satisfies [1.3.1,2.3].
2026-02-09 02:27:28 -05:00
eugene yokota 3e3cde19b9
[2.x] fix: Disk cache label (#8716)
**Problem**
Currently symlink hit is reported separately from the disk cache,
which is not necessary.

**Solution**
Rename the symlink label to disk.
2026-02-07 23:40:16 -05:00
PandaMan de2c27abeb
[2.x] fix: handle --script-version sbt 2.x project dirs (#8715)
When in an sbt 2.x project directory, the script used to delegate to sbtn
before checking --script-version, so 'sbt --script-version' ran sbtn and
failed. Now we print the script version and exit before the native client
branch.
2026-02-07 22:16:21 -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
eugene yokota 499ec520a7
[2.x] require coreutils for RPM (#8712)
**Problem**
Apparently sbt can fail when it doesn't have rm,
which can happen "when building relocatable RPM's and building an OS image in a chroot."

**Solution**
It was suggested that we require coreutils.
2026-02-07 17:23:39 -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 4681dc714c
Merge pull request #8705 from eed3si9n/wip/console-task-follow-up
[2.x] client-side console and fixes
2026-02-07 01:07:58 -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
PandaMan 3af62be0a3
[2.x] fix: Respect explicit platform settings in dependency resolution (#8697)
**Problem**
When platform is set, it incorrectly adds the platform suffix to implicit Scala library dependencies even though they explicitly set platform to jvm. This causes resolution errors.

**Solution**
Modified addPlatformSuffix to prioritize explicit platform settings on dependencies. If a dependency has an explicit platform, use that instead of the project platform. The project platform should only apply to dependencies without an explicit platform.

Fixes #8665
Generated-by: Claude Sonnet 4.5
2026-02-06 10:16:20 -05:00
calm c4a88328da
[2.x] fix: handle NoSuchFileException during cache storage (#8699) 2026-02-06 06:36:07 -05:00
bitloi 52bc35e3a9
[2.x] fix: allow defining root project with extraProjects (#4976) (#8694)
When an AutoPlugin adds a project at the build root via extraProjects,
avoid creating a second root from the build definition so both do not
share the same target directory. Treat extraProjects root as 'root
already defined' and exclude the build-defined root from initialProjects
when both would be at the same base.
2026-02-05 19:07:30 -05:00
Pluto 12deebba2b
[2.x] fix: restore CLI precedence over .sbtopts
According to the issue, `.sbtopts` entries are appended after
CLI args in sbt 1.12.x, so `.sbtopts` JVM memory settings (e.g., `-Xmx2g`) override CLI `--mem`,
causing invalid JVM settings.
2026-02-05 18:04:55 -05:00
Angel98518 949c3ab04f
[2.x] Replace commented System.err.println with proper logger.debug (#8693)
**Problem**
The writeSuite() method in JUnitXmlTestsListener had a commented-out System.err.println statement with a TODO to use proper logging.
2026-02-05 16:22:15 -05:00
bitloi 54548041cf
[2.x] feat: Ivyless Maven repo publish (#8692)
- Add ivylessPublishMavenToFile and ivylessPublishMavenToUrl for Maven layout
- Handle MavenCache and MavenRepo in ivylessPublishTask (file + HTTP)
- Add credentialFor for realm+host credential matching per Publishing docs
- Consume HTTP response body on success to avoid connection leak
- Add scripted tests: ivyless-publish-maven, ivyless-publish-maven-http
2026-02-05 11:21:31 -05:00
bitloi 2f27b5cecd
[2.x] fix: extraProjects with auto-root aggregate breaks key aggregation (#8690)
When using the aggregated key parser, a key is now valid if it exists in `data` for that scope **or** it's an aggregate key and every key it aggregates to exists in `data`. So `(root, scripted)` is accepted when the root aggregates a project that defines `scripted`, and running `scripted` at root runs it on that project as before.
2026-02-04 23:25:47 -05:00
bitloi b460bb871e
[2.x] feat: Ivyless publish to Ivy repo (#8686)
Implements ivyless publish task as part of #7639 (drop Ivy dependency).
Fixes #8639.

- Add ivylessPublish for URLRepository: HTTP PUT with optional Basic auth,
  same layout as ivyless publishLocal (artifacts + ivy.xml + checksums).
- Add ivylessPublishToFile for FileRepository: write to local path for
  testing without HTTP server.
- Add ivylessPublishTask: when useIvy is false, use ivyless path for
  URLRepository or FileRepository; otherwise use Ivy.
- Wire publish in Defaults to LibraryManagement.ivylessPublishTask
  (tagged Publish, Network).
- Add scripted test dependency-management/ivyless-publish using
  Resolver.file to verify ivyless publish produces identical layout.

Credentials supported via allCredentials (Basic auth for PUT).
2026-02-04 14:20:38 -05:00
bitloi b0601b4c6c
[2.x] fix: Fixes subproject deps with different Scala versions (#8681)
When a project depended on another project that was built with a different Scala binary version (e.g. 2.12 vs 2.13), compilation could fail with "not found: value X" because resolution was asking for the wrong artifact.

This change updates how we build the `ModuleID` for inter-project dependencies in `projectDependenciesTask`: we now request the dependency’s Scala binary version (e.g. `bar_2.12`) instead of the current project’s, so the resolver can find the right artifact. We keep existing behavior for `Disabled` and `Constant` cross-version, and add a small safeguard in the default case when the dependency’s Scala version differs from the current project’s.
2026-02-03 13:40:00 -05:00
eugene yokota 5ba750059c
[2.x] Bump to sbtn 1.12.1 (#8683) 2026-02-03 02:05:50 -05:00
eugene yokota 5131b8658a
[2.x] Use JProcess for interactive forking (#8677)
**Problem/Solution**
For forking that require both input and output,
use a Java process instead of the Scala process.
2026-02-02 11:03:28 -05:00
bitloi 4c16466672
[2.x] feat: Support Maven BOM (Bill of Materials) (#8675)
**Consuming BOMs**

- You can declare a BOM with `.pomOnly()` and versionless deps with `"*"`:
  - `libraryDependencies += ("com.fasterxml.jackson" % "jackson-bom" % "2.21.0").pomOnly()`
  - `libraryDependencies += "com.fasterxml.jackson.core" % "jackson-core" % "*"`
- BOMs are passed to Coursier via `Resolve.addBom()`; version `"*"` is resolved from the BOM.

**makePom**

- POM-only dependencies are emitted under `<dependencyManagement><dependencies>...</dependencies></dependencyManagement>` with `<type>pom</type>` and `<scope>import</scope>`.
- Dependencies with version `"*"` are emitted without a `<version>` element so Maven uses the BOM-managed version.

**Ivy / publishLocal emulation**

- When publishing to Ivy (e.g. `publishLocal`), BOM-resolved versions (deps that had `"*"`) are written into the published `ivy.xml` as forced dependencies (`force="true"`), so consumers that depend on this module get those versions.
2026-02-02 10:54:43 -05:00
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