Building a Spring Boot maven project with Lombok dependency using -Xlint:all compiler option produces a compiler warning
COMPILATION WARNING :
-------------------------------------------------------------
No processor claimed any of these annotations: org.springframework.boot.autoconfigure.SpringBootApplication
1 warning
-Xlint -enables all recommended warnings, see javac docs for more details.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<compilerArgs>
<arg>-Werror</arg>
<arg>-Xlint:all</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
COMPILATION WARNING :
-------------------------------------------------------------
No processor claimed any of these annotations: org.springframework.boot.autoconfigure.SpringBootApplication
1 warning
-------------------------------------------------------------
-------------------------------------------------------------
COMPILATION ERROR :
-------------------------------------------------------------
warnings found and -Werror specified
1 error
-------------------------------------------------------------
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
If you remove lombok dependency from the pom file, the project builds successfully.
Might be related to this bug in Lombok.
This doesn't really have anything to do with Lombok specifically. It will happen with any annotation processor on the classpath. The warning is indicating that annotation processing was performed during compilation and that none of the annotation processors handled an annotation. Note that there's nothing special about @SpringBootApplication
and that it'll warn about any unhandled annotation
IMO, it's not a very helpful warning as it assumes that every annotation in a project's code will be handled by an annotation processor. Given that anyone can write an annotation and that there are many other uses for annotations other than processing during compilation, that assumption seems flawed to me.
I think you have two choices:
@SupportedAnnotationTypes
to declare all of the annotations that you want to use in your code that you don't want to be warned about.I tried your second proposed solution:
@SupportedAnnotationTypes("org.springframework.*")
public class AnnotationProcessor extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
return true;
}
}
and now I get this warning
No processor claimed any of these annotations: javax.annotation.processing.SupportedAnnotationTypes,org.springframework.boot.autoconfigure.SpringBootApplication
Same result when trying to declare all annotations
@SupportedAnnotationTypes("*")
I'd guess your annotation processor is not running as an annotation processor but is having its source processed by an annotation processor. That would explain why it hasn't removed org.springframework.boot.autoconfigure.SpringBootApplication
and has added javax.annotation.processing.SupportedAnnotationTypes
to the list of unprocessed annotations.
You can add -Xlint:-processing
to your compiler arguments to silence this warning. You can combine this with -Xlint
or -Xlint:all
to still run lint on everything else.
Most helpful comment
You can add
-Xlint:-processing
to your compiler arguments to silence this warning. You can combine this with-Xlint
or-Xlint:all
to still run lint on everything else.