Skip to content
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

Moshi annotation processor not recognized #454

Closed
gabrielittner opened this issue Aug 26, 2021 · 7 comments
Closed

Moshi annotation processor not recognized #454

gabrielittner opened this issue Aug 26, 2021 · 7 comments
Labels
bug Something isn't working
Milestone

Comments

@gabrielittner
Copy link
Contributor

Build scan link

Reproducer
kapt-moshi.zip

Plugin version

0.76.0

Gradle version

7.0 and 7.2

(Optional) Android Gradle Plugin (AGP) version

4.2.1 and 7.0.1

Describe the bug

I'm using Moshi's annotation processor through kapt. When running buildHealth I get

> Task :settings:findDeclaredProcsDebug
Could not reflectively access processor class com.squareup.moshi.kotlin.codegen.JsonClassCodegenProcessor

> Task :buildHealth
Advice for root project
Looking good! No changes needed

Advice for project :settings
Plugin advice:
- kotlin-kapt: this project has the kotlin-kapt (org.jetbrains.kotlin.kapt) plugin applied, but no annotation processors (or no used annotation processors), which is redundant.

BUILD SUCCESSFUL in 1s

So it seems that the plugin specifically fails to access JsonClassCodegenProcessor and then reports kapt as unused because there are no other processors.

To Reproduce
Steps to reproduce the behavior:

  1. Add kapt("com.squareup.moshi:moshi-kotlin-codegen:1.12.0") to a project
  2. Declare a data class with @JsonClass(generateAdapter = true)

Expected behavior

kapt is not reported as unused.

Additional context

This is the only processor where I see this happening, others like Dagger or moshi-sealed seem fine.

Side note: Even when adding

issues {
    all {
        onAny {
            severity('fail')
        }
    }
}

the plugin reporting kapt as unused does not fail the build. Might be another bug.

@autonomousapps
Copy link
Owner

Once again, thanks for the reproducer.

@autonomousapps autonomousapps added the bug Something isn't working label Aug 28, 2021
@autonomousapps autonomousapps added this to the 1.0 milestone Aug 28, 2021
@autonomousapps
Copy link
Owner

I think that

issues {
    all {
        onAny {
            severity('fail')
        }
    }
}

is another, or maybe just a misleading API. onAny only configures dependency violations, vs plugin violations. You could use onRedundantPlugins instead. If you think that should have different behavior, would you please file a feature request?

@autonomousapps
Copy link
Owner

Resolved via related PR.

@gabrielittner
Copy link
Contributor Author

I think that ... is another, or maybe just a misleading API. onAny only configures dependency violations, vs plugin violations. You could use onRedundantPlugins instead. If you think that should have different behavior, would you please file a feature request?

The API is a bit misleading I'd say. I think it would be enough to update that you have on the configuration snippet here https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin/wiki/Customizing-plugin-behavior#failure-conditions-and-filtering

@autonomousapps
Copy link
Owner

I agree it's confusing. It's a historical artifact. The plugin didn't originally give advice regarding plugins. Do you mind filing an issue?

@gabrielittner
Copy link
Contributor Author

Opened #462

After updating to 0.77.0 the fix for moshi works but I noticed that the processor analysis also fails on Dagger: Could not reflectively access processor class dagger.internal.codegen.ComponentProcessor. I guess I didn't notice it before because we only have dagger in 3 checked projects and our build is fairly noisy. Do you want an extra reproducer for dagger?

@autonomousapps
Copy link
Owner

autonomousapps commented Aug 30, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants