Skip to content

Instantly share code, notes, and snippets.

@esamson
Last active May 2, 2022 12:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esamson/0777b97adde4c2f9bc31 to your computer and use it in GitHub Desktop.
Save esamson/0777b97adde4c2f9bc31 to your computer and use it in GitHub Desktop.
Maven and javax.annotation.processing.Messager NOTE messages.
<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>
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);
}
}
}
@tchemit
Copy link

tchemit commented Jan 7, 2018

Do you know if there is a way to activate the profile when you add -X (or --debug) option in command line?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment