Commit Graph

17676 Commits

Author SHA1 Message Date
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
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
kenji yoshida 56c86a1684
[2.x] Delete TrapExitSecurityException (#8503) 2026-01-12 19:11:35 -05:00
kenji yoshida f31290b809
[2.x] Update project/PublishBinPlugin.scala (#8498)
avoid useCoursier. prepare sbt 2
2026-01-12 16:20:23 -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 fe6125d8d1
[2.x] feat: Cache failed compilation to avoid repeated failures (#8490)
When a compilation fails with CompileFailed, the failure is now cached
so that subsequent builds with the same inputs don't re-run the failed
compilation. This significantly improves the experience when using BSP
clients like Metals that may trigger many compilations in a row.

The implementation:
- Adds CachedCompileFailure, CachedProblem, and CachedPosition types
  to serialize compilation failures
- Modifies ActionCache.cache to catch CompileFailed exceptions and
  store them in the cache with exitCode=1
- On cache lookup, checks for cached failures first and re-throws
  the cached exception if found
- Fixes DiskActionCacheStore.put to preserve exitCode from request
- Adds unit test to verify cached failure behavior

Fixes #7662
2026-01-12 16:03:05 -05:00
kenji yoshida bc32efbea6
refactor: Add parentheses to PathFinder.get (#8497) 2026-01-12 15:19:40 -05:00
kenji yoshida 0fa17f7705
Update sbt plugins (#8496) 2026-01-12 15:19:07 -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
MkDev11 0ec500392f
[2.x] ci: Handle undefined crossScalaVersions in publishLocalAllModule (#8491)
The publishLocalAllModule command fails with 'crossScalaVersions is
undefined' when the zinc submodule's compilerBridge project doesn't
have crossScalaVersions defined.

This is a long-standing issue that was reported in #4387 (2018) and
'magically resolved' when zinc happened to define the setting, then
resurfaced in #7607 (2024) when zinc changed.

The fix uses getOpt().getOrElse(Nil).toList instead of get().toList
to handle the case where crossScalaVersions is not defined, allowing
the command to proceed gracefully.

Fixes #7607
2026-01-12 01:42:39 -05:00
eugene yokota 88812f27a3
Merge pull request #8494 from calm329/fix/8442-server-subprocess-hang-linux
[2.x] fix: Prevent server subprocess hang on Linux (#8442)
2026-01-12 00:50:42 -05:00
calm329 476730aba2 fix: Prevent server subprocess hang on Linux (#8442) 2026-01-11 21:00:57 -08:00
calm e7323171a2
fix: Handle relocated dependencies in dependencyTree (#8400) (#8489) 2026-01-11 21:27:11 -05:00
MkDev11 21b5c3b8df
[2.x] fix: Fix snapshot sbt version invalidation 7713 (#8486)
When using a SNAPSHOT version of sbt, if the sbt jars are republished
with breaking binary changes, the build definition should be recompiled.
Previously, the cache key only considered the source content, not the
classpath, causing NoSuchMethodError when cached classes referenced
methods that no longer exist.

This fix includes a hash of SNAPSHOT and -bin- jars (including their
modification times) in the cache key. When these jars change, the build
definition is recompiled.

Fixes #7713
2026-01-11 21:01:05 -05:00
eugene yokota 4606c90f69
[2.x] ci: Integrate launcher package (#8485)
**Problem/Solution**
This is a follow up to launcher package migrating to sbt 1.x.
This joins the launcher package into the main build.
2026-01-11 20:57:59 -05:00
xuwei-k e5d05ca584 Update mimaPreviousArtifacts and mimaBinaryIssueFilters 2026-01-12 10:31:21 +09:00
xuwei-k d3f7f6bf90 Add test for 8458 2026-01-12 10:03:00 +09:00
byteforge bd03184cf5
[2.x] Fix ProjectMatrix invalid project ID with CrossVersion.full (#8484)
When using `ProjectMatrix` with `CrossVersion.full` and Scala 2 versions like `2.13.18`, the project ID incorrectly became `$1$2_13_18` instead of `foo2_13_18`.

**Root cause:** The Scala 3 compiler creates synthetic intermediate vals (e.g., `$1`) during macro expansion. The `enclosingTerm` function in the macros was stopping at these synthetic symbols instead of continuing up the symbol tree to find the actual val name.

**Fix:** Added `Flags.Synthetic` check to skip compiler-generated symbols in:
- `main-settings/src/main/scala/sbt/std/KeyMacro.scala`
- `lm-core/src/main/scala/sbt/librarymanagement/ConfigurationExtra.scala`

---------

Co-authored-by: byteforge38 <joseph.mc0803@gmail.com>
2026-01-11 19:17:26 -05:00
xuwei-k 813078695f Avoid deprecated java.net.URL constructor
- https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/net/URL.html#%3Cinit%3E(java.lang.String)
- https://bugs.openjdk.org/browse/JDK-8295949
2026-01-12 08:46:04 +09: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 61899ecd16
ci: Use slash syntax in build.sbt (#8481) 2026-01-11 15:46:00 -05:00
eugene yokota 697e32e496
[2.x] docs: Minor tweaks to the docs (#8480) 2026-01-11 15:08:20 -05:00
MkDev11 985cf94bb7
fix: Only disable symlinks when truly not supported (#8479) 2026-01-11 13:04:37 -05:00
kenji yoshida 113b6eb103
Use SAM-conversion if possible (#8477) 2026-01-11 07:21:28 -05:00
kenji yoshida 2338d5f4ee
Fix scaladoc (#8476) 2026-01-11 07:20:40 -05:00
kenji yoshida 072181499a
Fix BuildServerTest (#8475) 2026-01-11 07:20:10 -05:00
MkDev11 db06acb31e
test: Migrate CacheSpec to verify.BasicTestSuite (#8474)
Migrate CacheSpec from ScalaTest AnyFlatSpec to verify.BasicTestSuite
following the project's test framework standardization.

Changes:
- Convert class to object extending BasicTestSuite
- Replace ScalaTest 'should/in' syntax with test() method
- Replace fail() with assert(false, message)
- Replace === with ==
- Use Scala 3 indentation-based syntax
- Remove ScalaTest import, add verify.BasicTestSuite import

All tests pass successfully.

Fixes #8466

Generated-by: Cascade (AI pair programmer)
2026-01-11 07:19:22 -05:00
MkDev11 bbeeb25422
[2.x] fix: Upgrade launcher-package to sbt 1.10.7 and replace dispatch-http (#8465)
Fixes #7826

Changes:
- Upgrade sbt version from 0.13.18 to 1.10.7 in launcher-package/project/build.properties
- Remove dead dispatch-http 0.8.10 dependency from plugins.sbt
- Update sbt-native-packager from 1.7.6 to 1.10.4 (com.github.sbt)
- Update sbt-pgp from 2.1.2 to 2.3.1
- Replace all dispatch.classic._ HTTP calls with Java URL.openStream()

The dispatch-http library is dead and doesn't support sbt 1.x. This change
uses standard Java networking APIs for HTTP downloads, eliminating the
dependency on outdated libraries.

All HTTP download operations now use:
- java.net.URL.openConnection()
- InputStream with buffered reading
- Proper resource cleanup with try-finally blocks

- Removes the sbt-export-repo plugin dependency
- Defines exportRepo and exportRepoDirectory settings locally
- Removes ExportRepoPlugin from dist project
- Fixes exportRepo task to not reference itself

* fix: Update PackageSignerPlugin.scala for sbt 1.x compatibility
- Use withExtension instead of copy(extension = ...) for Artifact
- Update Classpaths.publishConfig to use sbt 1.x signature with all required parameters
- Use new slash syntax for scoped keys (pgpSigner / skip instead of skip in pgpSigner)

* fix: Use computed status instead of status key in PackageSignerPlugin

* fix: Use withRevision instead of copy for ModuleID in build.sbt

- Add scala.sys.process._ import for shell command execution (! method)
- Fix resolvers setting to use new slash syntax and proper Option handling
- Fix publish/publishLocal to use {} instead of () to avoid deprecation warning
- Fix Classpaths.publishTask to use variant without delivery key (deprecated since 1.1.1)
- Add scala.sys.process._ import for shell command execution
- Fix publish/publishLocal to use {} instead of ()
- Remove problematic resolvers setting that caused task/setting dependency issues
- Use IvyActions.publish directly instead of deprecated Classpaths.publishTask
- Fix ModuleID.copy to use withRevision
- Fix Artifact.copy to use withExtension
- Use computed status value instead of status key

Build now compiles successfully with sbt 1.10.7.
2026-01-11 07:17:24 -05:00
eugene yokota 877ea0435c
Merge pull request #8473 from sbt/eed3si9n-patch-1
Fix typo in link to CONTRIBUTING.md
2026-01-11 03:57:26 -05:00
eugene yokota 39a5c804ed
Fix typo in link to CONTRIBUTING.md 2026-01-11 03:57:14 -05:00
eugene yokota 4c88d27397
Merge pull request #8472 from eed3si9n/wip/contributing-docs
[2.x] docs: Contributor's Guide
2026-01-11 03:54:57 -05:00
eugene yokota d7fde4d376
Merge pull request #8456 from tellorian/fix/8429-actioncache-symlink-optimization
[2.x] Fix #8429: Add symlink optimization to ActionCache.get
2026-01-11 03:40:54 -05:00
Eugene Yokota 51638d342c docs: Contributor's Guide
**Problem**
We probably need some guidance on contributions.

**Solution**
Here's a contributor guide.
2026-01-11 03:24:30 -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
eugene yokota 2b819e24d1
Merge pull request #8470 from xuwei-k/String-toString
[2.x] refactor: Remove redundant `String#toString`
2026-01-11 03:17:57 -05:00
eugene yokota 4ff1d77e26
Merge pull request #8469 from xuwei-k/redundant-asInstanceOf
[2.x] Remove redundant `asInstanceOf`
2026-01-11 03:16:56 -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 3015bab1d7 Remove redundant asInstanceOf 2026-01-11 16:43:17 +09:00
xuwei-k c0fe4dfb10 Add tailrec annotation 2026-01-11 16:33:45 +09:00
eugene yokota 4bee8747e9
Merge pull request #8463 from MkDev11/fix/dependency-overrides-ivy-7951
[2.x] Fix #7951: Apply dependencyOverrides to delivered Ivy XML
2026-01-10 21:09:09 -05:00
tellorian d63191bb16
Merge branch 'develop' into fix/8429-actioncache-symlink-optimization 2026-01-11 09:39:49 +09:00
mkdev11 7389f1e059 Merge develop and resolve conflicts 2026-01-11 01:45:38 +02:00
mkdev11 e63a4b8f8c Refactor applyDependencyOverrides into testable function 2026-01-11 01:40:51 +02:00
eugene yokota 9ba3966ad2
Merge pull request #8460 from MkDev11/fix/gc-monitor-warning-8002
[2.x] fix: Improve GCMonitor warning message clarity
2026-01-10 16:24:01 -05:00
MkDev11 9475f278b5
Merge branch 'develop' into fix/dependency-overrides-ivy-7951 2026-01-10 12:51:54 -08:00