7

I'm developing an annotation processor. And here is a classic maven project structrue.

project
- src/main
  - java // SOURCE_PATH
  - resources // SOURCE_PATH
- target
  - classes // CLASS_PATH and CLASS_OUTPUT
  - generated-sources
    - annotations // SOURCE_OUTPUT

Everything is ok in maven with javac. But when I want to intergrate it into eclipse, I find eclipse apt only support CLASS_OUTPUT and SOURCE_OUTPUT.

I think CLASS_OUTPUT is also ok because it's equals to CLASS_PATH. Then I get the following exception

org.eclipse.core.internal.resources.ResourceException: Resource '/test-annotation-use-processer/target/classes/config.properties' does not exist.
    at org.eclipse.core.internal.resources.Resource.checkExists(Resource.java:335)
    at org.eclipse.core.internal.resources.Resource.checkAccessible(Resource.java:209)
    at org.eclipse.core.internal.resources.File.getContents(File.java:275)
    at org.eclipse.core.internal.resources.File.getContents(File.java:268)
    at org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeInputFileObject.openInputStream(IdeInputFileObject.java:86)

Well, the file does exists in disk. I don't know what's wrong for eclipse.

Is there any workaround to get resource in eclipse apt?

Dean Xu
  • 4,438
  • 1
  • 17
  • 44
  • Did you create/import the project as a maven project in Eclipse? Eclipse has built-in support for maven projects. – AJNeufeld Apr 03 '18 at 13:46
  • @AJNeufeld Of course. The problem is about 'the built-in support'. – Dean Xu Apr 03 '18 at 13:48
  • 1
    do you really keep you 'test-annotation-use-processer' project in the file-system root? Since path to the resource in the stack-trace starts with '/', means that this is an absolute path, not relative to your working dir, right? – andrii Apr 12 '18 at 19:32
  • @andrii The string (resource uri) is given by `Filer`. I think it is relative to eclipse workspace (a vitrual path). If not, it is a bug for eclispe. – Dean Xu Apr 13 '18 at 00:06

0 Answers0