Last active
May 2, 2022 12:12
-
-
Save esamson/0777b97adde4c2f9bc31 to your computer and use it in GitHub Desktop.
Maven and javax.annotation.processing.Messager NOTE messages.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project> | |
<!-- Add the following compiler configuration to make | |
- annotation processor messages show up in Maven output. | |
--> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<configuration> | |
<showWarnings>true</showWarnings> | |
<compilerArgs> | |
<arg>-Adebug=true</arg> | |
</compilerArgs> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.annotation.processing.SupportedOptions; | |
@SupportedOptions("debug") // declare the `debug` option | |
public final class InYourProcessor extends AbstractProcessor { | |
/** | |
* This is now your logging routine. | |
*/ | |
private void log(String msg) { | |
if (processingEnv.getOptions().containsKey("debug")) { | |
processingEnv.getMessager().printMessage(Kind.NOTE, msg); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you know if there is a way to activate the profile when you add -X (or --debug) option in command line?