Code Generator
This interface allows for easy extension of Anvil's core compiler functionality for cases where you need to generate extra code during compilation.
This interface is loaded via java.util.ServiceLoader and you should package a service file for your implementations accordingly. As such, order of execution is not guaranteed.
A CodeGenerator can generate arbitrary Kotlin code, whether it be for Anvil or Dagger or both! Note that the generated code must be Kotlin code. Java, arbitrary resource files, etc are not supported.
Functions
Called multiple times in order to create new code. Note that instances should not rely on being able to resolve projectFiles to descriptors. They should rather use the Psi APIs to parse files.
Returns true if this code generator is applicable for the given context or false if not. This will only be called once.
Extensions
Write content into a new file for the given packageName and fileName. fileName usually refers to the class name.