gnodet opened a new issue, #12643:
URL: https://github.com/apache/maven/issues/12643
## Context
PR #12572 (Build Report Foundation) introduced a warning collection pipeline
that intercepts SLF4J WARN-level log calls via
`BuildReportCollector.captureLogEvent()` and auto-creates `BuilderProblem`
objects with synthetic keys (`auto:xxx`).
However, Maven already creates **structured** `BuilderProblem` objects
during model/settings/toolchains validation (with `key`, `suggestion`,
`documentationUrl`, `source:line:column`). These are currently re-logged as
plain text by `DefaultProjectsSelector` and `DefaultMaven.buildGraph()`, losing
all structured metadata.
## Problem
When the SLF4J hook intercepts the re-logged text, it creates a new
synthetic `BuilderProblem` with:
- An auto-generated key (`auto:logger-name:hash`) instead of the original
meaningful key
- No `suggestion`
- No `documentationUrl`
- No source location
The original structured `BuilderProblem` data is discarded.
## Proposed Solution
### Phase 1: Model validation problems
In `DefaultProjectsSelector` and `DefaultMaven.buildGraph()`, after logging
model problems at WARN level, pipe the original `BuilderProblem` directly into
`DefaultDiagnosticCollector`:
```java
// Current code:
LOGGER.warn(problem.getMessage());
// Proposed:
LOGGER.warn(problem.getMessage());
diagnosticCollector.report(problem); // preserves key, suggestion, docUrl,
source location
```
The SLF4J hook should then skip auto-creating a synthetic problem when a
structured one was already reported for the same message (dedup by message
hash).
### Phase 2: Settings and toolchains validation
In `LookupInvoker` (line 746) and `MavenInvoker` (line 218), same pattern —
pipe settings/toolchains `BuilderProblem` objects directly instead of only
logging their message text.
### Phase 3: Plugin Validation Manager
`DefaultPluginValidationManager` operates a completely separate warning
collection pipeline with its own `ConcurrentHashMap<String,
PluginValidationIssues>`. The session-end summary is logged at WARN (captured
by SLF4J hook), but the individual plugin validation issues (deprecated mojos,
Maven 2 deps, etc.) with their plugin GAV, locality, and mojo info are lost.
Create structured `BuilderProblem` objects for each plugin validation issue
and report them to the `DiagnosticCollector`, enriched with:
- `key`: e.g. `plugin-deprecated-mojo`, `plugin-maven2-dependency`
- `source`: plugin GAV (`groupId:artifactId:version`)
- `suggestion`: e.g. "Update to Maven 4 API" or "Remove maven-compat
dependency"
- `documentationUrl`: link to Maven plugin development guide
### Validators affected
| Validator | Current behavior | After fix |
|-----------|-----------------|-----------|
| `DefaultModelValidator` (~35 sites) | BuilderProblem → re-logged as text →
lost | Structured piping |
| `DefaultSettingsValidator` (~15 sites) | BuilderProblem → re-logged as
text → lost | Structured piping |
| `DefaultToolchainsBuilder` | BuilderProblem → re-logged as text → lost |
Structured piping |
| `DeprecatedPluginValidator` | Own collection → session-end summary text |
Structured BuilderProblem |
| `Maven2DependenciesValidator` | Own collection → session-end summary text
| Structured BuilderProblem |
| `Maven3CompatDependenciesValidator` | Own collection → session-end summary
text | Structured BuilderProblem |
| `MavenScopeDependenciesValidator` | Own collection → session-end summary
text | Structured BuilderProblem |
| `ReadOnlyPluginParametersValidator` | Own collection → session-end summary
text | Structured BuilderProblem |
| Profile activators (File, JDK) | BuilderProblem → re-logged as text → lost
| Structured piping |
## Expected Outcome
`mvnlog` and `mvnlog --diagnostics` display the full structured information:
```
Problems: 2 warnings
[WARN] 'prerequisites' is deprecated pom.xml
key: deprecated-prerequisites
suggestion: Use the maven-enforcer-plugin instead
docs: https://maven.apache.org/pom.html#prerequisites
[WARN] Plugin uses deprecated Maven 2 API maven-shade-plugin:3.5.0
key: plugin-maven2-dependency
suggestion: Update to a version that uses Maven 4 API
```
## Depends on
- #12572 (Build Report Foundation)
--
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]