Skip to content

Add Scala 2.12 cross-building for all Scala 2 modules - #587

Open
jonoabroad wants to merge 2 commits into
softwaremill:masterfrom
ucroo:add-scala-2.12-support
Open

Add Scala 2.12 cross-building for all Scala 2 modules#587
jonoabroad wants to merge 2 commits into
softwaremill:masterfrom
ucroo:add-scala-2.12-support

Conversation

@jonoabroad

Copy link
Copy Markdown

What

Adds Scala 2.12.20 to the build matrix for every module that already builds for 2.13: core, openai, claude, gemini, agent-testkit, and the fs2/zio/pekko/akka streaming modules. The Scala 3-only modules (mcp, ox, examples, docs) and Scala Native targets are unchanged. Closes #586.

Shared sources stay cross-compatible rather than duplicated (~14 small adjustments):

  • 2.13-only stdlib calls replaced (toLongOption, Either.orElse, distinctBy).
  • sttp.ai.core.compat.unused: scala.annotation.unused doesn't exist on 2.12, so it's aliased on 2.13/3 and inert on 2.12 (warning category silenced on 2.12 rows only — 2.13 keeps full checking).
  • Immutable collections materialised where 2.12's default collection.Seq isn't accepted; type ascriptions where 2.12's inference fails.
  • Attachment now references assistants.Tool fully qualified — on 2.12 it silently bound the same-package Tool instead of the imported one (scala/bug#4695, fixed in 2.13).

ADR 0004 records the decision, the compat mechanisms, and the exit criterion; happy to drop or reword it if you'd rather record ADRs yourselves.

Verification

scalafmtCheckAll, compileDocumentation, and the full sbt test aggregate pass; 2.13/3 unit suites are unchanged and green. Integration tests were not run (they need live API keys) — happy to run them against our own keys before merge if useful.

🤖 Generated with Claude Code

jonoabroad and others added 2 commits August 12, 2026 08:09
Adds 2.12.20 to the build matrix for core, openai, claude, gemini,
agent-testkit and the fs2/zio/pekko/akka streaming modules. The Scala
3-only modules (mcp, ox, examples, docs) and Scala Native targets are
unchanged.

Source adjustments, all cross-compatible with 2.13 and 3:

- Replace 2.13-only stdlib calls: String.toLongOption, Either.orElse,
  Seq.distinctBy.
- Provide sttp.ai.core.compat.unused: scala.annotation.unused does not
  exist on 2.12, so it is aliased on 2.13/3 and an inert annotation on
  2.12 (with the warning category silenced on 2.12 rows only).
- Materialise immutable Seqs where 2.12's default scala.collection.Seq
  is not accepted (multipartBody in OpenAI.scala, pekko/akka Source in
  test specs).
- Add type ascriptions where 2.12's weaker inference fails (LoopAgent
  toolMap, SchemaSupport fold state, and two test specs).
- Qualify assistants.Tool in Attachment: 2.12 resolves same-package
  members ahead of explicit imports (scala/bug#4695, fixed in 2.13),
  which silently bound the wrong Tool type.

Docs updated to state 2.12 support.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

Would you accept Scala 2.12 cross-building for the Scala 2 modules?

1 participant