will FIR support classpath scanning of any sort? I...
# k2-adopters
z
will FIR support classpath scanning of any sort? In Anvil currently, it scans across the classpath from the module like so to accomplish some of its work in the frontend
d
No, it doesn't All it can is finding specific class/callable by it's FQN
r
Do you have any suggestion for what Anvil could do? The idea of Anvil is very basic. In several library modules classes say that they want to be contributed to a set. Anvil will generate a property for faster lookup in a special package. In the app module Anvil will merge all contributed classes to this set. It scans this special package for these properties to find all contributed classes. This process is quite fast. Without the scanning part, I’m not sure how it will work. In the IR backend Anvil still relies on the
ModuleDescriptor
exposed by `IrModuleFragment`: https://github.com/square/anvil/blob/071b46804423e7aa6579f8dc992370b41543423b/comp[…]ler/src/main/java/com/squareup/anvil/compiler/ClassScannerIr.kt In other words: Anvil needs to find all classes with a specific annotation across all dependencies on the compile classpath.
d
"_It scans this special package for these properties to find all contributed classes_" and "_Anvil needs to find all classes with a specific annotation across all dependencies on the compile classpath_" are two completely different things For me it looks like that the best way to do it is to write names of all annotated classes/your special properties into some file in resources of
.jar
during compilation of library and then just read this file for each library during compilation of application
r
The idea is to save the annotated classes for a quick lookup somewhere. At the moment Anvil creates properties for the class references in a special package. Then later it scans this package for these properties, which point to the class references. Do resources actually work? Do I get access to them from a compiler plugin? I never looked for such an API until now. The other concern with resources are Android projects, which don’t use resource file in their
.aar
files and make it harder to work with them.
d
There is no such API yet, but we plan to add it to K2 API
r
That sounds great!
z
Is there a Youtrack we could subscribe to?
d
r
Exactly what Anvil would need.