Zac Sweers
11/22/2022, 10:14 PMSymbolProcessor
that handles running Dagger’s.
• It would then decorate KSP’s Resolver
APIs to intercept them and add this metadata (annotations, etc) to the KSP types on their way through.
So for example, this type
@MergeComponent(...)
interface AppComponent
This processor would then intercept that and construct a new KSClassDeclaration
that almost entirely mirrors the previous except that it adds the merged @Component
annotation that anvil synthesizes instead.
Lastly, when resolving annotated elements, it would intercept searches for Component types and forward the request as a @MergeComponent
request instead.
Same patterns would be used for merged modules.
While weird and obviously not something KSP could officially support, I do think this could work more or less entirely within the bounds of KSP’s public API. Does this seem like a reasonable approach? Or any dragons on the path that I’d run into?Ting-Yuan Huang
11/22/2022, 11:34 PMksp(...)
dependencies into compiler plugin classpath and loads all processors discovered. You may need to fetch and load dagger separately, which can be error prone, or let's figure out how KSP can support this better.
2. The decorator will need to be maintained to keep up with KSP's APITing-Yuan Huang
11/22/2022, 11:39 PMenvironment
into javac's implementation.Jiaxiang
11/22/2022, 11:59 PMJiaxiang
11/22/2022, 11:59 PMZac Sweers
11/23/2022, 5:02 AMTing-Yuan Huang
11/23/2022, 9:41 PMksp
dependencies. Indirect dependencies will still be accessible in the plugin classpath, but KSP should not load them. In this way, Anvil can declare the dependency on Dagger, having them available in classpath, without running them automatically.
On the other hand, this is a behavior change. A processor previously worked with Dagger would then require its users to declare Dagger explicitlyZac Sweers
11/23/2022, 10:36 PM