-
Notifications
You must be signed in to change notification settings - Fork 278
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_proto_library doesn't support custom TypeMappers anymore? #751
Comments
cc @ianoc-stripe who may have some ideas. Would you be willing to make PR with a unit test that you would like to pass and we can see how we can get it to pass. My guess is that we will need to add the ability of adding extra dependencies to the scalapb toolchain since we can't customize the individual aspect generated targets in any way that I know of. |
@sholokhov you can add the dependencies to the scalapb toolchain which lets you add more deps. It will get added to all of the scalapb targets in one swoop in the repo. You can define |
@ianoc thanks for helping, but now it fails with following error (during well-known proto files compilation):
I've updated my repo with example, can you take a look please? Am I missing something? P.S: Correct me if I'm wrong, but if this schema works it means that all those implicit deps are gonna be propagated in all |
@sholokhov in the example, (sorry i should have been clearer on this) when you set the implicit compile deps you replace the existing ones. would show you making the example work. This obviously isn't great here since we are referencing something in private in the rules_scala for that default list (Internally we replace all of these deps pointed to targets fetched via bazel-deps, so we don't see this sort of challenge :/ ). We could make that a more public reference of But to try understand what you generally do here/if this is a good fit. The case in that repo looks to be mapping types on a message object, is that your main use case or services? Currently the aspect based model aligns pretty closely with the java proto rules aspects, the main deviation right now is that we have combined scala type generation with the grpc service generation. The java rules only use the aspect for the types but not the services. If there was a solid motivation that only applied to services it might make sense for us to split the two up too and not use the aspect for grpc. Another alternative is that if we trust the user not to 'cross' paths with the aspect and thus possibly generate 2 different sets of code for the same proto we could bring back some of the proto -> src jar/library methods too. |
Thanks for help, now it works for me despite that I don't really like to have a reference on private part of
We have a monorepo with all our services which are mostly gRPC based and services with type mappers are an exceptions. But the bad thing now is that we have one service that depends on mongo db driver and we use mapper to map some mongo entities:
So now the only way to make it work is actually include dependency on mongo db in proto toolchain which will affect all our services, even if they don't need mongo at all. Another thing (the same problem actually) - if we have some service specific types (like |
This is super interesting to see/hear. We don't use the type converters ourselves today either, so we haven't ran into this problem. Though it does sound thorny. I don't believe the java protobuf supports this at all so it doesn't come up there. Separating the grpc bindings from the scala generation itself doesn't sound like it would help here since this is all on the message types. There are 3 shapes of solutions here i can think of off hand:
|
@purkhusid Have you read the thread thoroughly? |
@ittaiz The workaround posted earlier in the thread is no longer viable. The implicit_compile_deps option is no longer there. Of the 2 solutions that @ianoc proposed i think 2. is better. Adding a bunch of dependencies to the toolchain will result in a lot of cache invalidation. What I was wondering is if it´s possible to have our cake and eat it too i.e. if it´s possible to have the rule aspect based and also add extra deps on the target level. I´m not experienced enough with aspects to know the answer but it would be awesome if some aspect expert could chime in. |
right, that one I know. |
@ittaiz Do you use the aspect based rules at wix or do you have something custom? If you have a custom rule, is it something that you could share? |
We use the aspect based rules. @simuons can you share a bit more about what you're working on since I have a feeling it somewhat correlates to @purkhusid's needs |
Hi @purkhusid, currently at wix we use aspects based rules. But right now we are moving to combination of aspects based rules for messages and custom rules for services. |
Yes it looks very similar. In addition I need ability to change generator and take more than one
Probably yes, but not sure in which form. I would contribute it as a whole rule if I'll make it general enough or it might be a set of functions which would ease writing such rule (if the end rule would contain to many Wix specifics). For example
It's less of a problem in #1114 since you generating code and compiling it for single |
Ah, that clears things up, If I understand you correctly then this would not be a problem if the rule would require all dependencies to be declared. E.g.
I was trying to go that route with my rule in #1114 but I'm not experienced enought with bazel/rules_scala to figure out how I exclude the transitive dependencies in the compilation. I think this is the route that |
Any progress on this? I ran into several of these problems recently as well. I'm also dealing with a large monorepo, so just "add a new common dependency that applies to all |
Hi!
After switching on aspect-based protobuf compilation (#700) it seems like it's no longer possible to use custom
TypeMapper
from ScalaPB. At the first glance the reason is that bazel tries to generate scala code fromproto_library
(%name-fast
rule) but there is no way to specify scala libraries forproto_library
(at least I haven't found).It feels like it used to work before because previously bazel was using
scalapb_proto_library
with itsdeps
to generate final scala code, where you can specify additional custom classes.I've also prepared small example which reproduces this issue.
Bazel version -
0.25.2
rules_scala -
b2e12827240fc488bbe5ebbbbcbc7a4f12ca02f2
The text was updated successfully, but these errors were encountered: