Report structured BuilderProblems from compiler diagnostics - #1101
Draft
gnodet wants to merge 2 commits into
Draft
Report structured BuilderProblems from compiler diagnostics#1101gnodet wants to merge 2 commits into
gnodet wants to merge 2 commits into
Conversation
Map javax.tools.Diagnostic to BuilderProblem and report via the new DiagnosticReporter service, so compiler warnings and errors appear with structured keys, source locations, and severity in the build report and mvnlog --diagnostics output. - Add @Inject DiagnosticReporter to AbstractCompilerMojo - Pass DiagnosticReporter to DiagnosticLogger constructor - Map each Diagnostic to BuilderProblem with key "compiler:<code>", severity from Diagnostic.Kind, and source file/line/column - Use per-type key for dedup (e.g. "compiler:compiler.warn.unchecked" counts all unchecked warnings as one summary entry) - Bump mavenVersion to 4.1.0-SNAPSHOT for DiagnosticReporter API - Update test imports for maven-testing package relocation - Add no-op DiagnosticReporter provider in test configuration Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
CI status: This PR is ready for review but will only pass CI once Maven core #12572 is merged and a SNAPSHOT is deployed. Tests pass locally against a locally-installed 4.1.0-SNAPSHOT (16/16 pass, 0 checkstyle violations). |
Change the BuilderProblem key from per-type (compiler:<code>) to per-location (compiler:<code>:<source>:<line>) so each unique file+line keeps its own entry in the build report. Warnings of the same type in different files are no longer collapsed into a single entry. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Maps
javax.tools.DiagnostictoBuilderProblemand reports via the newDiagnosticReporterservice from Maven 4.1.0, so compiler warnings and errors appear with structured keys, source locations, and severity in the build report andmvnlog --diagnosticsoutput.Related: apache/maven#12644 — follow-up to apache/maven#12572 (Build Report Foundation).
Changes
AbstractCompilerMojo: Add@Inject DiagnosticReporter diagnosticReporterDiagnosticLogger: AcceptDiagnosticReporterin constructor; for eachjavax.tools.Diagnostic, create aBuilderProblemwith:key("compiler:<code>:<source>:<line>")— per-location dedup key, e.g.compiler:compiler.warn.unchecked:src/main/java/Foo.java:42severitymapped fromDiagnostic.Kind(ERROR→ERROR, WARNING→WARNING, etc.)source,lineNumber,columnNumberfrom the diagnosticToolExecutor: PassdiagnosticReporterthrough toDiagnosticLoggerpom.xml: BumpmavenVersionto4.1.0-SNAPSHOTforDiagnosticReporterAPIDesign decisions
"compiler:<code>:<source>:<line>"as the key, so each unique file+line gets its own entry in the build report. This preserves per-file detail — 10 unchecked warnings across 10 files produce 10 separate entries, not one collapsed entry with count=10.-Dmaven.diagnostic.suppress=compiler:*(all) orcompiler:compiler.warn.unchecked(specific prefix).DiagnosticReporteris additive.Test changes
maven-testingpackage relocation (4.0.0-rc-4 → 4.1.0-SNAPSHOT)DiagnosticReporterprovider in test DI configurationTest plan
mvn test— 16 tests pass, 0 failuresDiagnosticReporterAPI from apache/maven#12572)Dependencies
This PR requires Maven core 4.1.0-SNAPSHOT which includes:
DiagnosticReporterservice (apache/maven#12572)BuilderProblem.builder()withkey(),suggestion(),documentationUrl()fields