Make eclipse handle changes to a custom annotation processor properly

Hello there,
I’m currently trying to get my own annotation processor to work properly and run into issues when using eclipse.

My setup is the following:

  • I have a main project
  • I have a subproject called “ap” that contains an annotation processor, to generate classes. This project also contains a few annotations that drive the class generation.
  • The main project depends on ap. Gradle generates ap.jar, and then used that jar to load the annotation processor.

The problem:
When I edit the annotation processor files, I want eclipse to compile the new annotation processor and then also actually use it.
I managed to get gradle to recreate the ap.jar when I modify the processor files in my latest commit. Although eclipse still uses the old annotation processor until I “refresh the project” (F5) or restart eclipse.
Also useful would be if eclipse would automatically regenerate all the files the annotation processor created, since its logic changed they will be different.

An idea how I would achieve that?

Here is my
build.gradle, and the entire project.

Regards,
Fabian

Annotation processors are not supported by Buildship. You can try creating an Eclipse plugin that contributes to the incvocationcustomizers extension.

Not sure I want to manually call into the eclipse API. Isn’t there a way to force eclipse to reload the paths from gradle?

There might be a chance to implement this without an Eclipse plugin.

It seems the annotation processor path can is configured with a single .factorypath file in the project. You could create a Gradle task that generates that file.

Then, you can configure Buildship to run this task as part of the project synchronization: EclipseModel (Gradle API 7.4)…-

plugins {
  id 'eclipse'
}

eclipse {
    synchronizationTasks​("generateFactoryPathFile")
}