Skip to content

[2.x] fix: Fix updateSbtClassifiers using wrong Scala version for cross-built plugins#8495

Merged
eed3si9n merged 4 commits intosbt:developfrom
calm329:fix/8026-update-sbt-classifiers-cross-plugin
Jan 12, 2026
Merged

[2.x] fix: Fix updateSbtClassifiers using wrong Scala version for cross-built plugins#8495
eed3si9n merged 4 commits intosbt:developfrom
calm329:fix/8026-update-sbt-classifiers-cross-plugin

Conversation

@calm329
Copy link
Copy Markdown
Contributor

@calm329 calm329 commented Jan 12, 2026

Summary

  • Fix updateSbtClassifiers to use the correct Scala version when building cross-compiled sbt plugins with explicit scalaVersion

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:

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)

Test plan

  • Added scripted test dependency-management/i8026-update-sbt-classifiers-cross-plugin
  • Verified existing tests pass:
    • dependency-management/update-sbt-classifiers
    • dependency-management/i8405-update-sbt-classifiers-plugins
    • dependency-management/sources
    • dependency-management/cache-classifiers
    • plugins/plugin-cross
  • MiMa binary compatibility check passed
  • Unit tests passed

Fixes #8026


Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=148254234

Copy link
Copy Markdown
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@eed3si9n eed3si9n merged commit ebc11f0 into sbt:develop Jan 12, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cross-building sbt plugins: updateSbtClassifiers fails downloading wrong scripted-plugin artifact when scalaVersion is explicitly set in build.sbt

2 participants