Skip to content

Fix Scala 3 context arguments in generated gRPC routers - #934

Merged
mkurz merged 2 commits into
playframework:mainfrom
mkurz:fix-scala3-grpc-router-context
Nov 19, 2026
Merged

mkurz merged 2 commits into
playframework:mainfrom
mkurz:fix-scala3-grpc-router-context

Conversation

@mkurz

@mkurz mkurz commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Pekko gRPC 2.0.0 automatically enables scala3_sources for Scala 3 builds. Generated handlers then take (using system: ClassicActorSystemProvider), but Play's router templates still pass (system). A Scala 3 sample using the published generator fails with E172: no given ClassicActorSystemProvider.

Use service.scalaCompatConstants.ImplicitUsing in both router templates so the call matches the handler's Scala 2 or Scala 3 syntax. Add eight regression cases covering both syntax modes, regular/action routers and power APIs.

Enable scala3_sources in Scala 3 integration fixtures as well; those fixtures previously generated Scala 2 syntax, leaving the failing consumer path untested. Import the two generated serializers explicitly so the tests work with both Scala 2 implicits and Scala 3 named givens.

Resolve the Twirl compatibility templates' Pekko gRPC sources JAR as a required dependency in a private build configuration. The generator now uses artifact metadata to locate it and works when optional IDE classifier downloads are absent. The build-only sources dependency stays out of the compile classpath and published POM.

Validation:

  • Full tests (clean; testFull) passed on Java 25 with Scala 2.13.18 and 3.3.9, with optional classifier downloads disabled.
  • Generator tests passed with Scala 2.12.21 and 3.9.0, including the eight router regression cases and all eleven Twirl compatibility template modules.
  • Reproduced the CI missing-sources error before the dependency fix and verified the same missing-classifier setup passes afterward.
  • Confirmed the Scala 3 router variants fail before the template fix; the real Scala 3 sample also reproduced E172 before the fix.
  • Scala formatting, sbt formatting, Java formatting and header checks passed; git diff --check is clean.
  • Verified the build-only sources dependency is omitted from both published generator POM variants and the compile classpath.

@mergify

mergify Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@mkurz
mkurz force-pushed the fix-scala3-grpc-router-context branch from 0829830 to feadc0c Compare November 19, 2026 15:52
The Twirl compatibility generator needs pekko-grpc-codegen's sources
JAR. Resolve it as a normal dependency in a private configuration instead
of assuming optional IDE classifier downloads always contain it.

Select the source artifact by metadata and keep the build-only dependency
off the compile classpath and out of the published POM.
Pekko gRPC 2 enables scala3_sources for Scala 3, so generated handlers take
their actor system through a using clause. Match that syntax in both Play
router templates.

Enable Scala 3 generation in the integration fixtures so CI exercises
this path, import the generated serializers by name, and cover both
syntax modes, router variants and power APIs in regression tests.
@mkurz
mkurz force-pushed the fix-scala3-grpc-router-context branch from feadc0c to 9f796eb Compare November 19, 2026 16:34
@mkurz
mkurz merged commit 8170b92 into playframework:main Nov 19, 2026
25 of 70 checks passed
@mkurz
mkurz deleted the fix-scala3-grpc-router-context branch November 19, 2026 16:52
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.

1 participant