Skip to content

Backport sbt 2.x cross-publishing support to series/0.18#1973

Merged
kubukoz merged 15 commits into
disneystreaming:series/0.18from
ghostbuster91:backport/sbt2-compat
Jun 18, 2026
Merged

Backport sbt 2.x cross-publishing support to series/0.18#1973
kubukoz merged 15 commits into
disneystreaming:series/0.18from
ghostbuster91:backport/sbt2-compat

Conversation

@ghostbuster91

Copy link
Copy Markdown
Contributor

Port of PR #1903 from series/0.19. The sbt plugin is now cross-published for both sbt 1.x (Scala 2.12) and sbt 2.x (Scala 3.8), using a Compat shim to abstract over the Settings type and other API differences.

PR Checklist (not all items are relevant to all PRs)

  • Added unit-tests (for runtime code)
  • Added bootstrapped code + smoke tests (when the rendering logic is modified)
  • Added build-plugins integration tests (when reflection loading is required at codegen-time)
  • Added alloy compliance tests (when simpleRestJson protocol behaviour is expanded/updated)
  • Updated dynamic module to match generated-code behaviour
  • Added documentation
  • Updated changelog

ghostbuster91 and others added 5 commits June 15, 2026 17:49
Port of PR disneystreaming#1903 from series/0.19. The sbt plugin is now cross-published
for both sbt 1.x (Scala 2.12) and sbt 2.x (Scala 3.8), using a Compat
shim to abstract over the Settings type and other API differences.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sbt 1.12.x is the first version whose sbtPluginExtra understands
major version "2", which is required for cross-publishing the plugin
against sbt 2.0.0-RC9.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Import sbtcompat.PluginCompat for toFiles/parseModuleIDStrAttribute
- Import Compat._ for Def.uncached extension method
- Wrap task bodies with Def.uncached (no-op under sbt 1, cached-task
  opt-out under sbt 2)
- Replace .map(_.data) with toFiles() using implicit FileConverter
- Replace .metadata.get(moduleID.key) with SbtCompat.moduleIDStr lookup
- Change Def.Setting[_] to Def.Setting[?] for Scala 3 compatibility
- Fix protobuf test glob pattern and remove pinned sbt version from
  multiple-artifacts-same-namespace

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread build.sbt Outdated
@kubukoz

kubukoz commented Jun 15, 2026

Copy link
Copy Markdown
Member

CI changes next?

ghostbuster91 and others added 3 commits June 15, 2026 19:18
This test was added to series/0.18 after the original sbt2 PR, so its
plugins.sbt was missing the dependency exclusion block needed when
running under sbt 2 / Scala 3.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Port of commit 754720f from series/0.19:
- Add sbt 2 excludeDependencies block to plugins.sbt
- Replace hardcoded target/scala-2.13/ path assertions with
  checkLayout sbt tasks that use Compile/sourceManaged, which
  resolves correctly under both sbt 1 and sbt 2

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kubukoz

kubukoz commented Jun 16, 2026

Copy link
Copy Markdown
Member

fwiw I would do it without scalafix specifically (the CI changes I mentioned were mostly supposed to achieve parallelism in the sbt1/2 builds)

ghostbuster91 and others added 3 commits June 16, 2026 15:46
…riants

Now that the sbt plugin is cross-published for sbt 1.x (codegenPlugin,
Scala 2.12) and sbt 2.x (codegenPlugin3, Scala 3.8), run each scripted
test as two explicit steps instead of relying on root-project aggregation
which is implicit and fragile.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
In sbt 2, java.io.File is not a valid output type for a cached task.
Three task bodies that return Seq[File] were missing the Def.uncached
wrapper that was already applied to the ModuleID-returning tasks:
- smithy4sCodegen (delegates to cachedSmithyCodegen)
- smithy4sAllDependenciesAsJars
- smithy4sGeneratedSmithyFiles (implements its own sbt 1 cache internally)

Def.uncached is a no-op on sbt 1 via Compat.DefOps.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ghostbuster91 ghostbuster91 force-pushed the backport/sbt2-compat branch from a8f71a4 to 559e7e9 Compare June 16, 2026 13:46
ghostbuster91 and others added 3 commits June 16, 2026 15:52
Add sbtVersion to the sbt-plugin matrix so each (test, sbtVersion)
combination runs as an independent job rather than sequentially within
one job. Also pull the relevant remote caches for sbt 2 scripted tests
(2_13_jvm and 3_0_jvm) since codegenPlugin3/publishLocal depends on
those artifacts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
In sbt 2, task keys returning java.io.File or Seq[File] must either use
virtual file refs or be marked @transient to opt out of caching. Without
this, any scripted-test build.sbt that overrides these keys (e.g.
smithyBuild := Some(...), smithy4sInternalDependenciesAsJars := Nil,
smithy4sAllDependenciesAsJars +=) fails to reload.

Backported from disneystreaming#1961.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ghostbuster91 ghostbuster91 marked this pull request as ready for review June 16, 2026 17:36
@kubukoz kubukoz merged commit 07f8bac into disneystreaming:series/0.18 Jun 18, 2026
79 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.

2 participants