https://kotlinlang.org logo
m

Maik

07/08/2021, 7:22 AM
Hi folks, I'm trying to build a compiler plugin to check if certain ID's are unique. The ID's are defined in the code as follows:
@ErrorID
val errorID: Long = 0x10A
The ID's are found using the annotation and then their value is checked. But now I have encountered a problem. I want to do the check in a project with multiple modules and I am not clear how to manage or persist data in the plugin across modules. Are there any possible solutions for such use cases and if so, what do they look like? I would be very happy about some helpful comments!
r

rnett

07/08/2021, 7:48 PM
You can't, really, as far as I'm aware. I would try to do something like producing a report file for each project (somewhere in
build/
), and then have a gradle task in the root project that checks each of them. But you may run into incremental compilation issues, as well.
l

louiscad

08/04/2021, 2:18 PM
I think you could keep a registry somewhere, so your compiler plugin can see what's already been built. That makes me think about annotations that are kept into the class files in the JVM BTW. Not sure about the build time impact of inspecting already built code a bit to find that, but definitely doable I think.
4 Views