Java APT how to break a maven1 build when some apt condition are true
I have an APT processor that display warnings on some conditions. My project is using a maven1 build calling ant:apt
How to make maven fails w开发者_如何学编程hen warning conditions are met ? (the processor can be modified)
Thanks.
The annotation processor needs to create a message of Kind ERROR
. This results in a Compilation Failure, which in turn will abort the ant build (unless the failonerror
parameter of the ant javac task is set to false
). (And this in turn should fail the maven task)
processingEnvironment
.getMessager()
.printMessage(Kind.ERROR, "your error message here");
(Acquire the ProcessingEnvironment through the processor's init method)
Reference:
- ProcessingEnvironment.getMessager()
- Messager.printMessage(Kind, CharSequence)
- Diagnostic.Kind.ERROR
精彩评论