ScalaPB
ScalaPB copied to clipboard
Allow customizing visibility of the models generated from third-party protos
The problem
otel4s provides a pure Scala implementation of the OpenTelemetry specification. The protocol models used by otel4s are generated from the third-party protos defined in opentelemetry-proto.
Currently, these models are generated in a public package, making them accessible on the classpath.
This poses a significant problem because opentelemetry-proto may introduce binary-breaking changes. As a result, any updates to the opentelemetry-proto can cause otel4s-sdk-exporter-proto to break binary compatibility.
https://scalapb.github.io/docs/faq/#how-do-i-mark-a-generated-case-class-private doesn't work because proto models are third-party.
The proposition
Perhaps we can extend the package-scoped options to allow customizing modifiers of a package?
import "scalapb/scalapb.proto";
package com.mypackage;
option (scalapb.options) = {
scope: PACKAGE
package_modifier: "private[com.mypackage]" // or "private"
};
The workaround
As a workaround, I customized the PB.generate task to override package and visibility afterward: https://github.com/typelevel/otel4s/pull/860.