-
-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate FlatPackage as a GeneratorOption. #873
base: master
Are you sure you want to change the base?
Deprecate FlatPackage as a GeneratorOption. #873
Conversation
This will trigger on imported files as well, which will break if a related runtime was not compiled with this option enabled. Since this is now supported as a package-level option, users can simply move to use that instead for compatibility.
@thesamet is there any additional thing that should be done to get this in? |
Before deprecating, I wanted to introduce a generator parameter that allows setting flat_package only under a certain package, so this option is not assumed for imported protos. |
Ok, I understood that users can simply define this for their own packages using What's the rationale for also supporting this via a generator parameter? From my own experience, having compiler parameters that alter the generated package / class names creates more friction than is actually worth. One problem this creates is for custom plugins that rely on the scalapb generated classes. You end up having to share the compiler options between them which isn't necessary if the package / naming information is self-contained in the |
There have been user feedback on preferring generator options passed through SBT, as opposed to adding a file that depends on scalapb.proto. I would anticipate more of this feedback when deprecating flat package since it's fairly popular option. The rationale you provided is spot on - that has been my reasoning for not continuing to add generator options. I haven't fully landed on how to proceed with this. A more drastic change could be to set |
Sounds like the end state should be one where Perhaps this deprecation cycle could work (each top-level item is a scalapb release):
The reason for introducing a new generator option and then removing it is to make the transition easier for people that have a large codebase: they would simply have to turn on the generator option once to get the previous behaviour back. Then using the new proto option would allow to move over to the new style on a per-file / package basis. For example, a user could go through these steps:
Obviously, users could go directly to adding the proto-level option, but that seems like a lot to ask given that the user was previously using the default behaviour.
|
81403c9
to
b8f54d4
Compare
Bumping this interesting topic to see if/how we can move on. As a user of
|
Could |
If we do that, some projects may be importing third-party protos and internal protos from other sub-projects, with the expectation that internal ones are flat-packaged but externals aren't. With this suggestion, how would they control how imported protos are interpreted? |
Indeed, package-wide settings are much easier to handle than artifact/project-wide ones... Giving it a try, although it looks quite complex: local projects or JAR exposing protos with already compiled ScalaPB stubs could expose the ScalaPB generator options that were used for compilation, so that downstream projects can themselves pass them as generator options, using include paths (as opposed to packages). I think Ivy extra attributes could be used to store this information in remote JARs, using the version-less generator artifact (as captured in
with XXXX being a proper encoding of, for example:
ScalaPB plugins could get the same treatment, provided sbt-protoc detects the ScalaPB compiler transitively included in their |
A simpler approach could if the external jars just throw in a proto file with package-scoped options for what they provide, and the end-user's project that ensures those protos are imported. Maybe the auto-import can be automated by sbt-protoc through convention on that proto file name within the external jar. |
The approach we take internally is to put a For example, say project A uses this layout:
Then if project B does I suppose a solution to this is to always import The alternative we've been using in some cases is to use file-level options, but this requires copy-pasting which is suboptimal as well... So if we want to inject the scalapb options, it'd to be in every file to deal with imports like shown here. |
I saw that you implemented this on commons-proto & sbt-protoc 🎄 I took the liberty to try it out from master and I think there is a corner case to handle: when the same JAR (
I guess the recommendation would work as a simple fix? |
Fixes scripted 10-scalapb-validate, see * scalapb/ScalaPB#873 (comment) * scalapb/scalapb-validate#70 Other changes * cacheClassLoaders is now deprecated, see thesamet/sbt-protoc@2a730a4 * The new classloader caching implementation resolves sandboxed generators artifacts earlier, even if they are no sources. That is the case for Test / protocGenerate, which was starting before codeGenProject / Compile / publishLocal, causing: > Error downloading com.lightbend.akka.grpc:akka-grpc-codegen_2.12: > 1.1.0-5-c5975cd5
Fixes scripted 10-scalapb-validate, see * scalapb/ScalaPB#873 (comment) * scalapb/scalapb-validate#70 Other changes * cacheClassLoaders is now deprecated, see thesamet/sbt-protoc@2a730a4 * Forcing recompilation is no longer necessary as the cache gets invalidated if a sandbox genererator classpath is updated, see thesamet/sbt-protoc@80824b0 * The new classloader caching implementation resolves sandboxed generators artifacts earlier, even if they are no sources. That is the case for Test / protocGenerate, which was starting before codeGenProject / Compile / publishLocal, causing: > Error downloading com.lightbend.akka.grpc:akka-grpc-codegen_2.12: > 1.1.0-5-c5975cd5
Fixes scripted 10-scalapb-validate, see * scalapb/ScalaPB#873 (comment) * scalapb/scalapb-validate#70 Other changes * cacheClassLoaders is now deprecated, see thesamet/sbt-protoc@2a730a4 * Forcing recompilation is no longer necessary as the cache gets invalidated if a sandbox genererator classpath is updated, see thesamet/sbt-protoc@80824b0 * The new classloader caching implementation resolves sandboxed generators artifacts earlier, even if they are no sources. That is the case for Test / protocGenerate, which was starting before codeGenProject / Compile / publishLocal, causing: > Error downloading com.lightbend.akka.grpc:akka-grpc-codegen_2.12: > 1.1.0-5-c5975cd5
Fixes scripted 10-scalapb-validate, see * scalapb/ScalaPB#873 (comment) * scalapb/scalapb-validate#70 Other changes * cacheClassLoaders is now deprecated, see thesamet/sbt-protoc@2a730a4 * Forcing recompilation is no longer necessary as the cache gets invalidated if a sandbox genererator classpath is updated, see thesamet/sbt-protoc@80824b0 * The new classloader caching implementation resolves sandboxed generators artifacts earlier, even if they are no sources. That is the case for Test / protocGenerate, which was starting before codeGenProject / Compile / publishLocal, causing: > Error downloading com.lightbend.akka.grpc:akka-grpc-codegen_2.12: > 1.1.0-5-c5975cd5
* move scalapb-validation sbt instructions to scripted * bump sbt-protoc for better integration with common-protos Fixes scripted 10-scalapb-validate, see * scalapb/ScalaPB#873 (comment) * scalapb/scalapb-validate#70 Other changes * cacheClassLoaders is now deprecated, see thesamet/sbt-protoc@2a730a4 * Forcing recompilation is no longer necessary as the cache gets invalidated if a sandbox genererator classpath is updated, see thesamet/sbt-protoc@80824b0 * The new classloader caching implementation resolves sandboxed generators artifacts earlier, even if they are no sources. That is the case for Test / protocGenerate, which was starting before codeGenProject / Compile / publishLocal, causing: > Error downloading com.lightbend.akka.grpc:akka-grpc-codegen_2.12: > 1.1.0-5-c5975cd5 * demonstrate usage of validate_at_construction Requires scalapb/scalapb-validate@8529a55
This will trigger on imported files as well, which will break if a related runtime was not compiled with this option enabled.
Since this is now supported as a package-level option, users can simply move to use that instead for compatibility.