Upgrade guide
Before upgrading
Upgrade the code generator and runtime together. Check that integrations such as JSON, Spark, validation and Common Protos support the ScalaPB release line you select.
Regenerate your Scala sources after changing the generator version. For managed
sources, run sbt clean compile. If you check generated sources into your project,
regenerate those files too; sbt clean does not remove them.
The changelog lists changes for each release, including maintenance releases and prereleases.
Migrating to ScalaPB 1.x
ScalaPB 1.x is currently a prerelease line. Review the notes for the particular version you are adopting, especially when upgrading between alpha releases.
- Scala 3 sources:
scala3Sources = truenow generates Scala 3-only syntax, including namedgivendefinitions. This output no longer compiles on Scala 2 with-Xsource:3. When cross-building, enable the option only for Scala 3. Imports of generated contextual instances may need.givenor an explicit named import. See Scala 3 settings. - Lenses: regenerate all sources and recompile dependent code. The generated
lens base is now
scalapb.lenses.ObjectLenson both Scala 2 and Scala 3. It is abstract; replace directnew ObjectLens(lens)calls withnew ObjectLens(lens) {}or a named subclass. - Text format: printing omits implicit scalar defaults and empty optional unboxed messages. Explicitly present defaults are preserved. If you compare text output in tests, review the expected output. See text format.
- Editions: follow the Editions guide for supported versions, schema features and differences from legacy proto2 behavior.
- JavaScript and Native: the runtime's deprecated
ByteString.bytesreturns a copy. UsetoByteArray(); code that needs a stable path should first assign the result to a localval.
Migrating to ScalaPB 0.7.x
See the legacy upgrade guide
for the move from com.trueaccord.scalapb to com.thesamet.scalapb.
Migrating from sbt-scalapb to sbt-protoc
See the legacy sbt plugin migration.