It seems like, I can't register my own annotation processor. But using Google's AutoService does register my annotation processor. And it works brilliantly.
So, I did place the javax.annotation.processing.Processor
file under resources/META-INF/services
directory that contains the package path of the implementation of AbstractProcessor. And I intenionally added error message that has to fail the build like below.
override fun process(annotations: MutableSet<out TypeElement>?, roundEnv: RoundEnvironment?) : Boolean {
processingEnv.messager.printMessage(Diagnostic.Kind.ERROR, "Some Error !!")
// Some work
}
And I did double-check my actions but I can not figure out what did go wrong in the first place.
So the real question is why Google's AutoService did work and mine did not? And that keeps bugging me.
The problem was the default way of registering the Annotation Processor does not seem to trigger on IDE. At least, this was my observation at first look.
After several tedious reviews, I compared Google AutoService's javax.annotation.processing.Processor
file and mine. Then, I figured that my own file naming was started with whitespace. And that was the reason that made me go a sleepless whole day. Even writing this made me blushed but I did want to share my misfortune so that other folks that encountered this kind of problem can check if they have this kind of error in their own work. I hope, this solution was what you were looking for.
Check out your javax.annotation.processing.Processor
file if you have any misspelled or extra character including whitespace.
And also a friendly recommendation that you might want to use Google's AutoService that does all the troublesome work for you.