The documentation of Maven Compiler plugin mentions the following:
annotationProcessors:
Names of annotation processors to run. Only applies to JDK 1.6+ If not set, the default annotation processors discovery process applies.
What is the default annotation processors discovery process here? Is there any other way to set up annotation processors than this configuration tag?
I've found that the Getting Started with the Annotation Processing Tool (apt) documentation mentions a default discovery procedure, but it works with factory classes not processors and unfortunately it uses the tools.jar
and com.sun
packages from the JDK. Is this the default annotation processors discovery process?
Annotations provide information to a program at compile time or at runtime based on which the program can take further action. An annotation processor processes these annotations at compile time or runtime to provide functionality such as code generation, error checking, etc.
As we briefly mentioned, annotations processors are typically used to inspect the codebase against the presence of particular annotations and, depending on use case, to: generate a set of source or resource files. mutate (modify) the existing source code. analyze the exiting source code and generate diagnostic messages.
The process of generating code at compile time to handle the annotations is called Annotation Processing. The annotation processor can validate, generate, and modify your code based on the annotations, which help you significantly reduce the amount of code you need to write.
The default way to make an annotation processor available to the compiler is to register it in a file in META-INF/services/javax.annotation.processing.Processor
. The file can contain a number of processors: each the fully-qualified class name on its own line, with a newline at the end. The compiler will default to using processors found in this way if none are specified.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With