We've got the following small system:
- One Java-Project containing an annotation processor to generate java-code. Let's call it "A"
- A second Java-Project that depends on "A" and uses its annotation processor. Let's call it "B"
- using gradle
We now want to feed "A" a specific configuration file. E.g. for telling it that the generated classes should have a specific suffix or some given annotations. But since "A" is supposed to be a dependency for several other projects, this configuration file MUST be given in "B". Best case: in the resources folder. So this is the flow we were thinking about:
- "B" gets built
- This triggers annotation processing of "A"
- "A" reads a configuration file that lays in "B"
- The generated classes are in the build-folder of "B"
Everything works totally fine, except that "A" is not able to read the configuration file.
So the question is: How do I give any information from "B" to "A" so that "A" uses it in the build-process of "B"? A path to a configuration file would be already sufficient. Or is there any other way to configure an annotation processor from a depending project?
Edit:
This is an example annotation processor that lays in "A"
@SupportedAnnotationTypes("...")
public class BlocklyAnnotationProcessor extends AbstractProcessor {
@SneakyThrows
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
// <-- THIS IS WHERE I NEED TO ACCESS THE CONFIG FILE
this.do.fancyStuff();
}
A configuration file might be a yaml. Pretty similar to application.yml as it is used in spring boot
processor:
suffix: Impl
This is the project structure
project_A
L src
L java
L AnnotationProcessor.java
project_B
L src
L java
L ClassToBeProcessedByA.java
L resources
L my_config_to_be_read_by_A.yml