I have a simple annotation processor that should read a configuration file from the same project as annotated classes. Structure example:
- myproject
- src
- main
- java
- my.package.SourceFile
- resources
- config.json
In the annotation handler, I am trying to read a file:
FileObject resource = processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH, "", "config.json");
but he throws it away FileNotFoundException. I also tried other ways, such as ../resources/config.json, (which produces Invalid relative name: ../resources/config.json). And I tried to put the configuration file in src/main/java(and even src/main/java/my/package) instead, which I don't like, but it still throws FileNotFoundException.
That would already help if I could filer.getResource()tell me where he looks. To find out, I tried to create a file:
filer.createResource(StandardLocation.SOURCE_OUTPUT, "", "dummy");
myproject/build/classes/main/dummy. , SOURCE_PATH, .