Working with annotation processors in Eclipse 4.6 Neon

usr-local-ΕΨΗΕΛΩΝ :

I am maintaining a Java 7 web project that uses multiline annotation to store certain constants.

I could configure Eclipse fine when I was using Mars, so I could launch Tomcat with that application deployed and it worked like a charm...

Until I upgraded! Now no annotation processing is done despite the configuration.

I have found that this problem is due to a feature of Eclipse 4.6, as documented here

Java 6 annotation processors are supported in the batch compiler and in the IDE. By design, Java 6 processors are only executed during a build, not while editing. (bug 188558)

The linked bug says, in brief, that annotation processing has been removed from Eclipse's incremental compilation (perhaps the Build automatically???) for legitimate reasons. And in fact when I compile my project in CI server using Ant, annotations get processed as usual.

But I can't run my project anymore in Eclipse. It fully depends on the correct processing of the Multiline annotation.

So far, I have tried to disable the Build Automatically flag and manually build the project. No result.

I also tried to go to Java Compiler -> Annotation processing -> Factory Path, select the multiline-string jar, go to Advanced properties and uncheck Run this container's processors in batch mode, despite the checkbox is counterintuitive (I mean, it should be named "Run in incremental mode" and unchecked by default, according to the above mentioned bug)

The application is a web application, so on every attempt I try to deploy it to local Tomcat.

What do you think I can do about it?

cybersam :

A couple of suggestions:

  1. The multiline annotation you are using only supports up to Java version 1.6. (For instance, MultilineProcessor specifies @SupportedSourceVersion(SourceVersion.RELEASE_6), and the recommended pom settings specify source and target values of 1.6.) If your package is building with a JDK Compliance Level greater than 1.6, this is probably why the annotations are being ignored.
  2. Instead of using that annotation, you could just hard-code the multiline strings to your string variables. It would make your code less readable, but builds will be faster.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=452207&siteId=1