elharo commented on code in PR #1027:
URL:
https://github.com/apache/maven-compiler-plugin/pull/1027#discussion_r3719815878
##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -1248,6 +1258,18 @@ public ToolExecutor createExecutor(DiagnosticListener<?
super JavaFileObject> li
return executor;
}
+ /**
+ * Simple utility to enforce a listener.
+ * @param listener caller provided listener.
Review Comment:
blank line
##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -885,6 +885,16 @@ final void
amendincrementalCompilation(EnumSet<IncrementalBuild.Aspect> aspects,
@Parameter(property = "maven.compiler.maxmem")
protected String maxmem;
+ /**
+ * Should maven log a summary of compiler messages (if any) by type.
+ * When there are a lot of messages of the same type (unchecked,
deprecation etc),
+ * it can make the output more readable.
+ *
+ * @since 4.0.0-beta-5
+ */
+ @Parameter(property = "maven.compiler.messageLogType", defaultValue =
"COMPILER")
+ protected MessageLogType messageLogType;
+
Review Comment:
I tend to think this belongs in Maven, not the logger
##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -885,6 +885,16 @@ final void
amendincrementalCompilation(EnumSet<IncrementalBuild.Aspect> aspects,
@Parameter(property = "maven.compiler.maxmem")
protected String maxmem;
+ /**
+ * Should maven log a summary of compiler messages (if any) by type.
Review Comment:
Summarize compiler messages by type.
##########
src/main/java/org/apache/maven/plugin/compiler/DiagnosticLogger.java:
##########
@@ -118,63 +134,67 @@ public void report(Diagnostic<? extends JavaFileObject>
diagnostic) {
if (message == null || message.isBlank()) {
return;
}
- MessageBuilder record = messageBuilderFactory.builder();
- record.a(message);
- JavaFileObject source = diagnostic.getSource();
- Diagnostic.Kind kind = diagnostic.getKind();
- String style;
- switch (kind) {
- case ERROR:
- style = ".error:-bold,f:red";
- break;
- case MANDATORY_WARNING:
- case WARNING:
- style = ".warning:-bold,f:yellow";
- break;
- default:
- style = ".info:-bold,f:blue";
- if (diagnostic.getLineNumber() == Diagnostic.NOPOS) {
- source = null; // Some messages are generic, e.g.
"Recompile with -Xlint:deprecation".
- }
- break;
- }
- if (source != null) {
- record.newline().a(" at ").a(relativize(source.getName()));
- long line = diagnostic.getLineNumber();
- long column = diagnostic.getColumnNumber();
- if (line != Diagnostic.NOPOS || column != Diagnostic.NOPOS) {
- record.style(style).a('[');
- if (line != Diagnostic.NOPOS) {
- record.a(line);
- }
- if (column != Diagnostic.NOPOS) {
- record.a(',').a(column);
- }
- record.a(']').resetStyle();
+ if (logType == MessageLogType.COMPILER || logType ==
MessageLogType.ALL) {
+ MessageBuilder record = messageBuilderFactory.builder();
+ record.a(message);
+ JavaFileObject source = diagnostic.getSource();
+ Diagnostic.Kind kind = diagnostic.getKind();
+ String style;
+ switch (kind) {
+ case ERROR:
+ style = ".error:-bold,f:red";
+ break;
+ case MANDATORY_WARNING:
Review Comment:
fallthrough is error prone
##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -885,6 +885,16 @@ final void
amendincrementalCompilation(EnumSet<IncrementalBuild.Aspect> aspects,
@Parameter(property = "maven.compiler.maxmem")
protected String maxmem;
+ /**
+ * Should maven log a summary of compiler messages (if any) by type.
+ * When there are a lot of messages of the same type (unchecked,
deprecation etc),
+ * it can make the output more readable.
Review Comment:
it can make --> this makes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]