-
-
Notifications
You must be signed in to change notification settings - Fork 124
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
Plugin fails to analyze Dagger usages #479
Comments
Thanks for the reproducer. I actually just noticed this myself the other day but didn't have time to investigate. This makes it so much easier. Regarding "Could not reflectively access...", what do you think would be a better solution? I'm open to improving this use-case. Warnings-as-errors? Something else? |
I was thinking that the plugin advice would say something like "Could not determine whether kapt is used because processor ... could not be accessed" instead of recommending the removal of kapt. That way even if you miss the log beforehand it's clear from the actual output. Currently you'd probably try removing kapt and then realize it was actually needed when things don't build anymore. It could still use the plugin advice severity |
That might be feasible. Would you mind filing a separate feature request for that? |
This is pretty interesting. The dagger AP has a pretty complex initialization compared to other APs I've looked at. It even uses Dagger itself (sigh). Here's the top of the stacktrace from the failing
So, at the very least, it's choking on the So there are a couple of options:
Turns out that getting the supported annotation types out of dagger requires two additional dependencies on the classpath:
The versions would obviously have to be variable -- wouldn't want to hardcode that. Gradle workers with isolated classloaders seem in order. And these are the types if I decide to punt:
Actually it turns out the problem is somehow more complicated. There already is a This project's dependency (not the plugin's!) on AGP brings along an older version of dagger. Because java classloading delegates to the parent first, when trying to load the dagger AP for analysis, when it needs to access the |
@gabrielittner you can workaround this right now by updating your buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("com.google.dagger:dagger:2.38.1")
classpath("com.squareup:javapoet:1.13.0")
}
} The annotation processor analysis is failing because it can't initialize the dagger AP due to classes from these dependencies missing from the build classpath. I will be working on resolving this transparently. |
Thanks for the workaround, that's helpful 👍 I've opened the extra feature request for our message discussion. |
Resolved, will be in the next release. |
Build scan link
Reproducer kapt-dagger.zip
Plugin version
0.78.0
Gradle version
7.0 and 7.2
Describe the bug
When Dagger is used with kapt the plugin will print
Could not reflectively access processor class dagger.internal.codegen.ComponentProcessor
and will then go ahead to suggestTo Reproduce
Steps to reproduce the behavior:
Expected behavior
Plugin does not fail to access the Dagger processor and does not suggest to remove kapt.
Additional context
I wonder if the behavior should generally be different if the access to a processor class fails. Maybe a different message for the plugin advice? In bigger builds it's easy to miss the "Could not reflectively access ..." message. I can open a feature request for that if you think it makes sense.
The text was updated successfully, but these errors were encountered: