Commit Graph

391 Commits

Author SHA1 Message Date
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
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 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 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
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
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
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
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
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 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
Eugene Yokota 19ca2911d2 Scala 3.8.1 2026-01-24 04:52:28 -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
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
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
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
MkDev11 b6cdfe0d81
[2.x] test: Test transitive cached task (#8579)
Co-authored-by: mkdev11 <noreply@users.noreply.github.com>
2026-01-19 22:40:37 -05:00
byteforge c5af677632
[2.x] feat: Support ... as testOnly pattern (#8577) 2026-01-19 18:45:29 -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
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
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
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
eugene yokota 570ca30f69
[2.x] test: Test -Werror in metabuild (#8510)
**Problem**
-Werror in the metabuild didn't work on sbt 1.x.

**Solution**
This adds test for it on sbt 2.x.
2026-01-13 04:28:27 -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
azdrojowa123 106b8b9978
[2.x] Always create symlinks to the cache in the target locations #8445 (#8461)
* always create symlinks to the cache in the target locations, even if the digest matches #8445
* create a test (currently failing even on #develop) that fails because if `zipPath` in `sbt.util.ActionCache.packageDirectory` is a symlink to the CAS, in later calls, this path in the CAS gets overridden by the new sources.

- in this test, after "run 1" in line 15, the produced file "target/out/jvm/scala-3.7.4/a/classes.sbtdir.zip" is a symlink to the CAS, let's call it SH1.
- when "run 3" is executed, `IO.zip` saves the new value to `zipPath`, which is "target/out/jvm/scala-3.7.4/a/classes.sbtdir.zip -> SH1", so SH1 gets overridden.
- when the last "run 1" is executed, the cache retrieves SH1, but it contains the data from "run 3" (the test fails with "actual A.x is 3").

* when packaging a directory into a zip, use a temp directory to avoid overwriting the cache #8461
2026-01-12 19:38:59 -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
calm e7323171a2
fix: Handle relocated dependencies in dependencyTree (#8400) (#8489) 2026-01-11 21:27:11 -05:00
xuwei-k d3f7f6bf90 Add test for 8458 2026-01-12 10:03:00 +09:00
xuwei-k 2d14adc721 avoid deprecated scala.App
7ddf329f6f/library/src/scala/App.scala (L65)
2026-01-09 20:10:28 +09: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
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 55aa1b52ff Disable task-cancel test 2025-12-27 02:37:32 -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 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
Eugene Yokota 9888aae7fa [2.x] Switch to using shaded-gson
Fixes https://github.com/sbt/sbt/issues/8334
2025-12-15 03:17:33 -05:00