-
Notifications
You must be signed in to change notification settings - Fork 4
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
Allow consumption of Anvil-KSP contribution annotations #68
base: main
Are you sure you want to change the base?
Allow consumption of Anvil-KSP contribution annotations #68
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The more I think about it, the more I would have liked seeing a separate module that generates bindings that kotlin-inject-anvil can understand instead of mixing the annotations into the existing :compiler
module. That makes the code harder to maintain long term. There is also the classpath issue I called out in other comments.
For example, for @ContributesBinding
and @ContributesTo
coming from the original Anvil, a separate symbol processor could have generated a component interface with the binding. kotlin-inject-anvil is extensible and that's how we handle custom annotations internally. I don't see a reason why the same mechanism cannot be used here. This would keep the core free of the original Anvil annotations.
...kotlin/software/amazon/lastmile/kotlin/inject/anvil/processor/ContributesBindingProcessor.kt
Outdated
Show resolved
Hide resolved
...main/kotlin/software/amazon/lastmile/kotlin/inject/anvil/processor/ContributesToProcessor.kt
Outdated
Show resolved
Hide resolved
...in/software/amazon/lastmile/kotlin/inject/anvil/processor/ContributesBindingProcessorTest.kt
Outdated
Show resolved
Hide resolved
Sure, I'll go the separate module route then. That would make it inherently opt-in. I hope that would still have place in this repo? |
Yes, I'm okay with keeping it in this repo. Any suggestion for the module name? |
I am locally calling it Also, the changes are kinda forcing me to create a |
Yes, that's why I wanted to throw in "dagger" into the module name. The supporting modules make sense. I meant to do this work earlier, because I had ideas about further optional extensions myself. Thanks for doing this :-) |
82ef6e7
to
5da5a0c
Compare
Just pushed an update with the support done in its own module, |
5a3673e
to
db388f6
Compare
Added bindings/components that use Anvil-KSP annotations to the I think I'll create a separate sample that uses the Anvil-KSP annotations instead though, to not add noise to the current one (in case people are using it as an implementation example). |
After making Anvil-KSP annotations KMP ready, it's now possible to have some level of interop between Anvil and kotlin-inject-anvil working.
This PR adds support to (Dagger) Anvil annotations to generate code similar to what kotlin-inject-anvil's own annotations would generate.
The unsupported parameters (parameters in Anvil annotations that kotlin-inject-anvil doesn't have a counterpart for) are logged as a warning. These warnings can be disabled by setting the ksp arg
kotlin-inject-anvil-ignore-dagger-anvil-unsupported-param-warnings
totrue
.To be able to reuse some of the processor code, some utilities were forked to their own artifact,
compiler-utils
. This includes things likeContextAware
orLOOKUP_PACKAGE
.Same story with the tests, there were some test utilities that would be very necessary for extra modules, and those were moved to a
compiler-test
module. It's been 0 days since I've missed testFixtures 😬