-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
scalapb-validate integration with akka-grpc #70
Comments
Thanks for opening this to centralize the discussion. I have started thinking about this, see scalapb/ScalaPB#873 (comment) & scalapb/protoc-bridge#158. |
Idea 1: One workaround that would work with current versions is to have users throw in a proto file into their project that gives package-scoped option to disable package validate;
import "scalapb/scalapb.proto";
option (scalapb.options) = {
scope: PACKAGE
flat_package: false
}; Idea 2: Building on idea 1, we can have a generator option that would have the same impact over specific packages, so akka-grpc users can exclude Idea 3: make a special case for |
We have settled on a variant of idea 1 (since we didn't want to change all source code): disable There is a gotcha with that, as Akka gRPC generators don't seem to handle package-level |
Idea 1 does not seem to work as activating |
I think we should change to make it possible for the the file-level option to override with a |
When a protobuf dependency jar contains a Scalapb-Options-Proto in its manifest, the mentioned file will get automatically added to the list of sources for the protoc invocation. This makes ScalaPB aware of the options used to compile the third-party jar. See scalapb/scalapb-validate#70
ScalaPB extensions are currently not registered in akka-grpc so the compiler plugin does not see them, I am sending a PR to akka-grpc shortly. |
Thanks! Does it impact the solution? akka-grpc might erroneously think that 'validate' is compiled with flat_package - but does the code it generates references it? |
It makes what I described in #70 (comment) easier (the scripted is precisely what we are using to workaround this issue). I believe it does not impact in any way the solution you are implementing. |
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
I think we can close this now that akka/akka-grpc#1264 verifies the integration with sbt-protoc 1.0.1 / scalapb-validate 0.2.1. Thanks for making the integration seamless! |
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
Actually there is still one thing missing: usage of import "scalapb/scalapb.proto";
import "scalapb/validate.proto";
option (scalapb.options) = {
scope: FILE
[scalapb.validate.file] {
validate_at_construction: true
}
};
From my understanding, we should either
private def isNonFlatDependency =
- (file.getPackage == "google.protobuf") || (file.getPackage == "scalapb")
+ (file.getPackage == "google.protobuf") || (file.getPackage.startsWith("scalapb")) Happy to open a PR for (2) on ScalaPB as it looks like the easiest. |
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
v0.2.2 is released with the manifest option - can you try it out? |
I just verified the fix with akka/akka-grpc@e4a39c6, thanks for the quick turnaround! And this time, I think we are good to close this. |
* 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
akka-grpc defaults to compiling with
flat_package=true
. This results in user's generated code to reference the flat-package location of Scala sources generated byvalidate.proto
. However, thevalidate.proto
shipped withscalapb-validate
, throughcommon-protos
defaults toflat_package=false
.The goal of this ticket is to come up with a straightforward way for akka-grpc users to use scalapb-validate.
The text was updated successfully, but these errors were encountered: