Report structured BuilderProblems from compiler diagnostics - #1101
Draft
gnodet wants to merge 1 commit into
Draft
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). |
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:" + diagnostic.getCode())— e.g.compiler:compiler.warn.uncheckedseveritymapped fromDiagnostic.Kind(ERROR→ERROR, WARNING→WARNING, etc.)source,lineNumber,columnNumberfrom the diagnosticToolExecutor: PassdiagnosticReporterthrough toDiagnosticLoggerpom.xml: BumpmavenVersionto4.1.0-SNAPSHOTforDiagnosticReporterAPIDesign decisions
"compiler:<code>"as the key, so 50 unchecked warnings produce a single summary entry with count=50. Individual per-file details remain in the build log.-Dmaven.diagnostic.suppress=compiler:*(all) orcompiler:compiler.warn.unchecked(specific).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 failuresmvn compile— 0 checkstyle violations, spotless cleanDependencies
This PR requires Maven core 4.1.0-SNAPSHOT which includes:
DiagnosticReporterservice (apache/maven#12572)BuilderProblem.builder()withkey(),suggestion(),documentationUrl()fields