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
Dagger codegen uses ImmutableMap.builderWithExpectedSize which is marked as @Beta #1569
Comments
Hello @perezd : Thank you for reaching out! I was the engineer that added this change of generating I was coding at Google and I was doing 20% work for the Dagger team for a while. I intend to keep myself involved in Dagger and Guava and keep helping, on and off, as soon as I have bandwidth. I'm aware of the Google Guava philosophy. I guess you mean the current situation is at odds with this, right? Anyways, could you paste us the bazel + errorprone compilation that halts your build, please? What's the error message you're seeing? I'd like to learn more. Thank you @perezd ! |
Thanks for the reply! You are correct, it seems that dagger generated code shouldn't be relying on @beta annotated fields according to the spirit of that annotation, and Bazel + Guava beta checker basically enforces that rule such that it becomes a fatal error unless you disable errorprone which is non-ideal. This is the error message Bazel provides:
This kicks in just after the codegen plugin produces a source code file and just before bazel goes to compile that into a classfile jar I suspect. |
Any thoughts on how to resolve this for Bazel/Errorprone users? |
Previously, I modified Dagger so that its generated code is using `builderWithExpectedSize` for immutable collections whenever it's available, i.e., Guava 23.1 or later: google/dagger#1094 Since `builderWithExpectedSize` is a @beta API, if a Bazel client project depends on Dagger, and if the depended Dagger is using Guava 23.1 or later, Dagger generates code that uses this Guava @beta API, which fails ErrorProne, thus failing Bazel build: google/dagger#1569 The same issue could also happen if a Maven client project has a `maven-compiler-plugin` that also uses ErrorProne. If the Guava team feel confident about those `builderWithExpectedSize` static factory methods, maybe it's time to remove `@Beta` for them altogether. Happy to discuss. Thank you! Reference: https://github.com/google/guava/wiki/PhilosophyExplained#beta-apis
Hey @perezd ! My current idea is to remove Meanwhile, for now, you might want to consider adding the following flag inside your
Tell me whether that works for your case. Let me know if you have any questions. Thank you for using Dagger! |
That would be great to remove @beta assuming guava team thinks it should no
longer be in beta. Definitely ideal!
…On Mon, Sep 2, 2019, 7:51 PM Michael Xin Sun ***@***.***> wrote:
Hey @perezd <https://github.com/perezd> ! My current idea is to remove
@beta for those builderWithExpectedSize methods, so when you depend on a
newer version of Dagger that depends on a newer version of Guava, you'll no
longer have this problem:
google/guava#3591 <google/guava#3591>
Meanwhile, for now, you might want to consider adding the following flag
inside your .bazelrc
<https://docs.bazel.build/versions/master/best-practices.html#bazelrc>,
so that you don't have to disable ErrorProne entirely:
# TODO(perezd): Remove this line when Dagger no longer depends on Guava `builderWithExpectedSize`
--javacopt="-Xep: BetaApi:WARN"
Tell me whether that works for your case. Let me know if you have any
questions. Thank you for using Dagger!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1569?email_source=notifications&email_token=AAAFA5XATDJQUY4TOBYVOQTQHXGM5A5CNFSM4IF4GWB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5W3OJI#issuecomment-527284005>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAFA5V4IETBCGYWLFV63S3QHXGM5ANCNFSM4IF4GWBQ>
.
|
Using latest released version of dagger, I've noticed that Map multibindings is making use of ImmutableMap.builderWithExpectedSize. When compiling code w/ Bazel + errorprone enabled its throwing a warning about this and halting my builds.
This goes against Google philosophy: https://github.com/google/guava/wiki/PhilosophyExplained#beta-apis
What is the best way to suppress this for my users (I am building a library on top of Dagger/Bazel). Perhaps the generated code could @SuppressWarnings("BetaApi") since we consider this safe?
The text was updated successfully, but these errors were encountered: