Reputation: 329
In our project we want to create unique identifiers for user interface dialogs. To make sure developers do not create duplicate identifiers for dialogs i created an annotation processor which check for a "Dialog annotation" (It contains the unique identifier) and creates an error through the Messager-class within the Eclipse Problems view if a duplicate identifier has been detected.
I expected the processor to process all classes annotated with the dialog annotation but he only does so if i invoke a complete build within Eclipse. But if i change a single dialog class and save it, the processor only processes this single dialog (I believe this is called incremental build), thus making it impossible for me to check if other dialogs already assigned the same identifier.
I tried setting Run this container's processors in batch mode
in the .factorypath
file but it did not seem to have an effect. The eclipse documentation of Factory Path Preferences
says about this option:
This option only applies to processors using the Java 5 Mirror APIs. It does not affect processors using the Java 6 annotation processing APIs.
I do use the Java 6 annotation processing API. So this does not seem to be an option either.
Is there any way to make it process all annotated classes - even the unchanged classes? I'm also glad to hear about other ways to adress the initial problem.
Upvotes: 0
Views: 137
Reputation: 32527
AnnotationProcessor will process only compiled classes, so no wonder you have troubles.
I assume that your processor collects all ids on runtime. It would be better store collected ids into cache (eg file) and check for occurences there insted of scanning all annotated classes (all classes to be exact) on every compilation. That way, only single compilation of class will be required to register id
. Every future modification will check against already compiled, unmodified classes withour rechecking them.
Upvotes: 1