How to run JSR269 annotaion handler in Eclipse Kepler with Java 7 and Maven

I am using eclipse Kepler and the compiler is configured to use Java 7. I have an annotation handler compatible with JSR269 in my class path (in the maven container).

What is the easiest way to run this annotation handler?

In fact, I expected that compiling Eclipse would automatically run this annotation handler during build, as it is compatible with JSR 269, but it is not. Why not - is it for performance reasons?

Note: building maven from the command line works fine.

After some research, it turned out that this can be configured in the project properties (Java Compiler - Annotation Processing - Factory Path). The question here is that of course I want to use the annotation processor .jar file, which is already in the class path (in the Maven container). How can I turn to him? I have not found a way to do this.

The best I came up with is to use the M2_REPO variable, and then manually add the processor path as follows:

 M2_REPO/com/gwtplatform/gwtp-processors/1.0.1/gwtp-processors-1.0.1.jar 

Obviously, the problem is that the processor is now listed in 2 places: in the maven pom file and in the eclipse project. How to avoid this?

+5
source share
1 answer

You need an m2e connector that automatically configures your Eclipse project to handle annotations.

The m2e connector used depends on how you configured annotation processing on the Maven side. If you simply rely on the maven-compiler-plugin to find your annotation handler or if you configured the maven-annotation-plugin for this, you can use JBoss's m2e-apt connector.

m2e-apt can be easily installed from the m2 detection dialog in Eclipse ("Window" → "Settings" → "Maven" → "Open" → "Open Directory"). Then plug the connector into Window → Preferences → Maven → Annotation Processing. When you are updating your Maven project now (right-click on the project and choose "Maven" → "Update Project ..."), then the annotation processing for the Eclipse project should be automatically configured in the dialog box described in your question.

+4
source

Source: https://habr.com/ru/post/921035/


All Articles